mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:37:43 +00:00
LibJS+LibUnicode: Store parsed Unicode locale data as full strings
Originally, it was convenient to store the parsed Unicode locale data as views into the original string being parsed. But to implement locale aliases will require mutating the data that was parsed. To prepare for that, store the parsed data as proper strings.
This commit is contained in:
parent
caf5b6fa6f
commit
d13142f015
4 changed files with 22 additions and 22 deletions
|
@ -400,7 +400,7 @@ static Optional<Extension> parse_extension(GenericLexer& lexer)
|
|||
return {};
|
||||
}
|
||||
|
||||
static Vector<StringView> parse_private_use_extensions(GenericLexer& lexer)
|
||||
static Vector<String> parse_private_use_extensions(GenericLexer& lexer)
|
||||
{
|
||||
// https://unicode.org/reports/tr35/#pu_extensions
|
||||
//
|
||||
|
@ -411,8 +411,8 @@ static Vector<StringView> parse_private_use_extensions(GenericLexer& lexer)
|
|||
if (!header.has_value())
|
||||
return {};
|
||||
|
||||
auto parse_values = [&]() -> Vector<StringView> {
|
||||
Vector<StringView> extensions;
|
||||
auto parse_values = [&]() -> Vector<String> {
|
||||
Vector<String> extensions;
|
||||
|
||||
while (true) {
|
||||
auto segment = consume_next_segment(lexer);
|
||||
|
@ -491,18 +491,18 @@ Optional<String> canonicalize_unicode_locale_id(LocaleID& locale_id)
|
|||
Title,
|
||||
};
|
||||
|
||||
auto append_sep_and_string = [&](Optional<StringView> const& string, Case case_ = Case::Lower) {
|
||||
auto append_sep_and_string = [&](Optional<String> const& string, Case case_ = Case::Lower) {
|
||||
if (!string.has_value())
|
||||
return;
|
||||
switch (case_) {
|
||||
case Case::Upper:
|
||||
builder.appendff("-{}", string->to_uppercase_string());
|
||||
builder.appendff("-{}", string->to_uppercase());
|
||||
break;
|
||||
case Case::Lower:
|
||||
builder.appendff("-{}", string->to_lowercase_string());
|
||||
builder.appendff("-{}", string->to_lowercase());
|
||||
break;
|
||||
case Case::Title:
|
||||
builder.appendff("-{}", string->to_titlecase_string());
|
||||
builder.appendff("-{}", string->to_titlecase());
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
@ -510,7 +510,7 @@ Optional<String> canonicalize_unicode_locale_id(LocaleID& locale_id)
|
|||
if (!locale_id.language_id.language.has_value())
|
||||
return {};
|
||||
|
||||
builder.append(locale_id.language_id.language->to_lowercase_string());
|
||||
builder.append(locale_id.language_id.language->to_lowercase());
|
||||
append_sep_and_string(locale_id.language_id.script, Case::Title);
|
||||
append_sep_and_string(locale_id.language_id.region, Case::Upper);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue