LibUnicode+Everywhere: Merge LibLocale back into LibUnicode

LibLocale was split off from LibUnicode a couple years ago to reduce the
number of applications on SerenityOS that depend on CLDR data. Now that
we use ICU, both LibUnicode and LibLocale are actually linking in this
data. And since vcpkg gives us static libraries, both libraries are over
30MB in size.

This patch reverts the separation and merges LibLocale into LibUnicode
again. We now have just one library that includes the ICU data.

Further, this will let LibUnicode share the locale cache that previously
would only exist in LibLocale.
This commit is contained in:
Timothy Flynn
2024-06-23 09:14:27 -04:00
committed by Andreas Kling
parent c9d9e1bb1f
commit ebdb92eef6
102 changed files with 675 additions and 711 deletions

View File

@@ -8,7 +8,7 @@
#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <LibLocale/ICU.h>
#include <LibUnicode/ICU.h>
#include <unicode/bytestream.h>
#include <unicode/casemap.h>
@@ -44,8 +44,8 @@ ErrorOr<String> String::to_lowercase(Optional<StringView> const& locale) const
auto resolved_locale = resolve_locale(locale);
icu::CaseMap::utf8ToLower(resolved_locale.locale, 0, Locale::icu_string_piece(*this), sink, nullptr, status);
if (Locale::icu_failure(status))
icu::CaseMap::utf8ToLower(resolved_locale.locale, 0, Unicode::icu_string_piece(*this), sink, nullptr, status);
if (Unicode::icu_failure(status))
return Error::from_string_literal("Unable to convert string to lowercase");
return builder.to_string_without_validation();
@@ -60,8 +60,8 @@ ErrorOr<String> String::to_uppercase(Optional<StringView> const& locale) const
auto resolved_locale = resolve_locale(locale);
icu::CaseMap::utf8ToUpper(resolved_locale.locale, 0, Locale::icu_string_piece(*this), sink, nullptr, status);
if (Locale::icu_failure(status))
icu::CaseMap::utf8ToUpper(resolved_locale.locale, 0, Unicode::icu_string_piece(*this), sink, nullptr, status);
if (Unicode::icu_failure(status))
return Error::from_string_literal("Unable to convert string to uppercase");
return builder.to_string_without_validation();
@@ -80,8 +80,8 @@ ErrorOr<String> String::to_titlecase(Optional<StringView> const& locale, Trailin
if (trailing_code_point_transformation == TrailingCodePointTransformation::PreserveExisting)
options |= U_TITLECASE_NO_LOWERCASE;
icu::CaseMap::utf8ToTitle(resolved_locale.locale, options, nullptr, Locale::icu_string_piece(*this), sink, nullptr, status);
if (Locale::icu_failure(status))
icu::CaseMap::utf8ToTitle(resolved_locale.locale, options, nullptr, Unicode::icu_string_piece(*this), sink, nullptr, status);
if (Unicode::icu_failure(status))
return Error::from_string_literal("Unable to convert string to titlecase");
return builder.to_string_without_validation();
@@ -93,8 +93,8 @@ static ErrorOr<void> build_casefold_string(StringView string, StringBuilder& bui
icu::StringByteSink sink { &builder };
icu::CaseMap::utf8Fold(0, Locale::icu_string_piece(string), sink, nullptr, status);
if (Locale::icu_failure(status))
icu::CaseMap::utf8Fold(0, Unicode::icu_string_piece(string), sink, nullptr, status);
if (Unicode::icu_failure(status))
return Error::from_string_literal("Unable to casefold string");
return {};