LibUnicode: Canonicalize locale private use extensions

This commit is contained in:
Timothy Flynn 2021-08-28 13:26:57 -04:00 committed by Linus Groh
parent 6f0cb52dc4
commit f897c2edb3
Notes: sideshowbarker 2024-07-18 05:04:21 +09:00
2 changed files with 12 additions and 1 deletions

View File

@ -323,8 +323,15 @@ TEST_CASE(canonicalize_unicode_locale_id)
test("en-z-bbb-0-aaa"sv, "en-0-aaa-z-bbb"sv);
test("EN-Z-BBB-0-AAA"sv, "en-0-aaa-z-bbb"sv);
test("en-x-aa"sv, "en-x-aa"sv);
test("EN-X-AA"sv, "en-x-aa"sv);
test("en-x-bbb-aa"sv, "en-x-bbb-aa"sv);
test("EN-X-BBB-AA"sv, "en-x-bbb-aa"sv);
test("en-u-aa-t-en"sv, "en-t-en-u-aa"sv);
test("EN-U-AA-T-EN"sv, "en-t-en-u-aa"sv);
test("en-z-bbb-u-aa-t-en-0-aaa"sv, "en-0-aaa-t-en-u-aa-z-bbb"sv);
test("EN-Z-BBB-U-AA-T-EN-0-AAA"sv, "en-0-aaa-t-en-u-aa-z-bbb"sv);
test("en-z-bbb-u-aa-t-en-0-aaa-x-ccc"sv, "en-0-aaa-t-en-u-aa-z-bbb-x-ccc"sv);
test("EN-Z-BBB-U-AA-T-EN-0-AAA-X-CCC"sv, "en-0-aaa-t-en-u-aa-z-bbb-x-ccc"sv);
}

View File

@ -580,7 +580,11 @@ Optional<String> canonicalize_unicode_locale_id(LocaleID& locale_id)
});
}
// FIXME: Handle pu_extensions.
if (!locale_id.private_use_extensions.is_empty()) {
builder.append("-x"sv);
for (auto const& extension : locale_id.private_use_extensions)
append_sep_and_string(extension);
}
return builder.build();
}