Commit 2bb5b40f authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

[Intl] Fix Intl/getCanonicalLocales/canonicalized-tags

and also fix part of test in intl402/Locale/likely-subtags

Improve Intl::ToLanguageTag to also handle -yes in -u- extension
Avoid removing if there are other text after -true and -yes before -

Bug: v8:7669, v8:8236
Change-Id: I59943651889602288e6978d0b1c875d89199fe33
Reviewed-on: https://chromium-review.googlesource.com/c/1383094Reviewed-by: 's avatarJungshik Shin <jshin@chromium.org>
Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58900}
parent f85a3554
......@@ -524,17 +524,24 @@ Maybe<std::string> Intl::ToLanguageTag(const icu::Locale& locale) {
}
CHECK(U_SUCCESS(status));
// Hack to remove -true from unicode extensions
// Hack to remove -true and -yes from unicode extensions
// Address https://crbug.com/v8/8565
// TODO(ftang): Move the following "remove true" logic into ICU toLanguageTag
// by fixing ICU-20310.
const char* kSepTrue = "-true";
size_t u_ext_start = res.find("-u-");
if (u_ext_start != std::string::npos) {
for (size_t sep_true =
res.find(kSepTrue, u_ext_start + 5 /* strlen("-u-xx") == 5 */);
sep_true != std::string::npos; sep_true = res.find(kSepTrue)) {
res.erase(sep_true, 5 /* strlen(kSepTrue) == 5 */);
// remove "-true" and "-yes" after -u-
const std::vector<std::string> remove_items({"-true", "-yes"});
for (auto item = remove_items.begin(); item != remove_items.end(); item++) {
for (size_t sep_remove =
res.find(*item, u_ext_start + 5 /* strlen("-u-xx") == 5 */);
sep_remove != std::string::npos; sep_remove = res.find(*item)) {
size_t end_of_sep_remove = sep_remove + item->length();
if (res.length() == end_of_sep_remove ||
res.at(end_of_sep_remove) == '-') {
res.erase(sep_remove, item->length());
}
}
}
}
return Just(res);
......
......@@ -521,9 +521,6 @@
# https://bugs.chromium.org/p/v8/issues/detail?id=7483
'annexB/built-ins/Function/createdynfn-html-close-comment-params': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=7669
'intl402/Intl/getCanonicalLocales/canonicalized-tags': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=8260
'intl402/Locale/constructor-non-iana-canon': [FAIL],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment