1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 20:08:13 +00:00

LibUnicode: Add helper methods to LocaleID and LanguageID for LibJS

Add a method to remove an extension type from the locale's extension set
and methods to convert a locale and language to a string without
canonicalization. Each of these will be used by LibJS.
This commit is contained in:
Timothy Flynn 2021-09-01 17:54:24 -04:00 committed by Linus Groh
parent a05419db55
commit 21c4922ac0
2 changed files with 88 additions and 0 deletions

View file

@ -16,6 +16,8 @@
namespace Unicode {
struct LanguageID {
String to_string() const;
bool is_root { false };
Optional<String> language {};
Optional<String> script {};
@ -51,6 +53,19 @@ struct OtherExtension {
using Extension = Variant<LocaleExtension, TransformedExtension, OtherExtension>;
struct LocaleID {
String to_string() const;
template<typename ExtensionType>
void remove_extension_type()
{
auto tmp_extensions = move(extensions);
for (auto& extension : tmp_extensions) {
if (!extension.has<ExtensionType>())
extensions.append(move(extension));
}
}
LanguageID language_id {};
Vector<Extension> extensions {};
Vector<String> private_use_extensions {};