mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:57:45 +00:00
LibUnicode+LibJS: Store locale keyword values as a single string
Previously, LibUnicode would store the values of a keyword as a Vector. For example, the locale "en-u-ca-abc-def" would have its keyword "ca" stored as {"abc, "def"}. Then, canonicalization would occur on each of the elements in that Vector. This is incorrect because, for example, the keyword value "true" should only be dropped if that is the entire value. That is, the canonical form of "en-u-kb-true" is "en-u-kb", but "en-u-kb-abc-true" does not change for canonicalization. However, we would canonicalize that locale as "en-u-kb-abc".
This commit is contained in:
parent
75657b79c6
commit
4f2bcebe74
5 changed files with 102 additions and 118 deletions
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibJS/Runtime/AbstractOperations.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/Intl/AbstractOperations.h>
|
||||
|
@ -193,9 +192,7 @@ static LocaleAndKeys apply_unicode_extension_to_tag(StringView tag, LocaleAndKey
|
|||
entry = &(*it);
|
||||
|
||||
// ii. Let value be entry.[[Value]].
|
||||
StringBuilder builder;
|
||||
builder.join('-', entry->types);
|
||||
value = builder.build();
|
||||
value = entry->value;
|
||||
}
|
||||
// c. Else,
|
||||
// i. Let entry be empty.
|
||||
|
@ -213,12 +210,12 @@ static LocaleAndKeys apply_unicode_extension_to_tag(StringView tag, LocaleAndKey
|
|||
// iii. If entry is not empty, then
|
||||
if (entry != nullptr) {
|
||||
// 1. Set entry.[[Value]] to value.
|
||||
entry->types = value->split('-');
|
||||
entry->value = *value;
|
||||
}
|
||||
// iv. Else,
|
||||
else {
|
||||
// 1. Append the Record { [[Key]]: key, [[Value]]: value } to keywords.
|
||||
keywords.append({ key, value->split('-') });
|
||||
keywords.append({ key, *value });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue