mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 20:59:16 +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:
parent
a05419db55
commit
21c4922ac0
Notes:
sideshowbarker
2024-07-18 04:53:34 +09:00
Author: https://github.com/trflynn89
Commit: 21c4922ac0
Pull-request: https://github.com/SerenityOS/serenity/pull/9749
Reviewed-by: https://github.com/linusg ✅
2 changed files with 88 additions and 0 deletions
|
@ -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 {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue