mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
LibLocale+LibJS: Make a locale canonicalization API a bit more ergonomic
Instead of taking an out-parameter, return the canonicalization result. This allows the API to be used where specs want to store the result and the original values in separate variables.
This commit is contained in:
parent
d292152e2e
commit
2c311448c7
Notes:
sideshowbarker
2024-07-17 03:35:16 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/2c311448c7 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/198
@ -499,7 +499,7 @@ LocaleResult resolve_locale(Vector<String> const& requested_locales, LocaleOptio
|
||||
if (auto* options_string = options_value.has_value() ? options_value->get_pointer<String>() : nullptr) {
|
||||
// 1. Let optionsValue be the string optionsValue after performing the algorithm steps to transform Unicode extension values to canonical syntax per Unicode Technical Standard #35 LDML § 3.2.1 Canonical Unicode Locale Identifiers, treating key as ukey and optionsValue as uvalue productions.
|
||||
// 2. Let optionsValue be the string optionsValue after performing the algorithm steps to replace Unicode extension values with their canonical form per Unicode Technical Standard #35 LDML § 3.2.1 Canonical Unicode Locale Identifiers, treating key as ukey and optionsValue as uvalue productions.
|
||||
::Locale::canonicalize_unicode_extension_values(key, *options_string);
|
||||
*options_string = ::Locale::canonicalize_unicode_extension_values(key, *options_string);
|
||||
|
||||
// 3. If optionsValue is the empty String, then
|
||||
if (options_string->is_empty()) {
|
||||
|
@ -491,7 +491,7 @@ String canonicalize_unicode_locale_id(StringView locale)
|
||||
return locale_data->to_string();
|
||||
}
|
||||
|
||||
void canonicalize_unicode_extension_values(StringView key, String& value)
|
||||
String canonicalize_unicode_extension_values(StringView key, StringView value)
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
@ -507,7 +507,7 @@ void canonicalize_unicode_extension_values(StringView key, String& value)
|
||||
auto result = locale.getUnicodeKeywordValue<StringBuilder>(icu_string_piece(key), status);
|
||||
VERIFY(icu_success(status));
|
||||
|
||||
value = MUST(result.to_string());
|
||||
return MUST(result.to_string());
|
||||
}
|
||||
|
||||
StringView default_locale()
|
||||
|
@ -128,7 +128,7 @@ Optional<LanguageID> parse_unicode_language_id(StringView);
|
||||
Optional<LocaleID> parse_unicode_locale_id(StringView);
|
||||
|
||||
String canonicalize_unicode_locale_id(StringView);
|
||||
void canonicalize_unicode_extension_values(StringView key, String& value);
|
||||
String canonicalize_unicode_extension_values(StringView key, StringView value);
|
||||
|
||||
StringView default_locale();
|
||||
bool is_locale_available(StringView locale);
|
||||
|
Loading…
Reference in New Issue
Block a user