mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 18:20:43 +09: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: 2c311448c7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/198
3 changed files with 4 additions and 4 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue