mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 07:39:16 +00:00
ICU-22727 fix addLikelySubtags for 5-8 chars lang codes
Fix C++ code, add tests for C, C++ and Java API
This commit is contained in:
parent
9e1c66daf7
commit
6d4cea57ed
4 changed files with 81 additions and 2 deletions
|
@ -157,14 +157,17 @@ _uloc_addLikelySubtags(const char* localeID,
|
|||
return;
|
||||
}
|
||||
|
||||
if (lang.length() > 3) {
|
||||
if (lang.length() == 4 && script.isEmpty()) {
|
||||
if (lang.length() == 4) {
|
||||
if (script.isEmpty()) {
|
||||
script = std::move(lang);
|
||||
lang.clear();
|
||||
} else {
|
||||
err = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return;
|
||||
}
|
||||
} else if (lang.length() > 8) {
|
||||
err = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t trailingLength = (int32_t)uprv_strlen(trailing);
|
||||
|
|
|
@ -3867,6 +3867,27 @@ const char* const basic_maximize_data[][2] = {
|
|||
// so "aaaa" is a well-formed unicode_language_id
|
||||
"aaaa",
|
||||
"aaaa",
|
||||
}, {
|
||||
// ICU-22727
|
||||
// unicode_language_subtag = alpha{2,3} | alpha{5,8};
|
||||
// so "bbbbb", "cccccc", "ddddddd", "eeeeeeee" are
|
||||
// well-formed unicode_language_subtag and therefore
|
||||
// well-formed unicode_language_id
|
||||
// but "fffffffff" is not.
|
||||
"bbbbb",
|
||||
"bbbbb",
|
||||
}, {
|
||||
// ICU-22727
|
||||
"cccccc",
|
||||
"cccccc",
|
||||
}, {
|
||||
// ICU-22727
|
||||
"ddddddd",
|
||||
"ddddddd",
|
||||
}, {
|
||||
// ICU-22727
|
||||
"eeeeeeee",
|
||||
"eeeeeeee",
|
||||
}, {
|
||||
// ICU-22546
|
||||
"und-Zzzz",
|
||||
|
@ -6048,6 +6069,16 @@ const errorData maximizeErrors[] = {
|
|||
"en_Latn_US_POSIX@currency=EURO",
|
||||
U_STRING_NOT_TERMINATED_WARNING,
|
||||
30
|
||||
},
|
||||
{
|
||||
// ICU-22727
|
||||
// unicode_language_subtag = alpha{2,3} | alpha{5,8};
|
||||
// so "bbbbb", "cccccc", "ddddddd", "eeeeeeee" are
|
||||
// well-formed unicode_language_id but "fffffffff" is not.
|
||||
"fffffffff",
|
||||
NULL,
|
||||
U_ILLEGAL_ARGUMENT_ERROR,
|
||||
0
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -3915,6 +3915,31 @@ LocaleTest::TestAddLikelyAndMinimizeSubtags() {
|
|||
"aaaa",
|
||||
"aaaa",
|
||||
"aaaa",
|
||||
}, {
|
||||
// ICU-22727
|
||||
// unicode_language_subtag = alpha{2,3} | alpha{5,8};
|
||||
// so "bbbbb", "cccccc", "ddddddd", "eeeeeeee" are
|
||||
// well-formed unicode_language_subtag and therefore
|
||||
// well-formed unicode_language_id
|
||||
// but "fffffffff" is not.
|
||||
"bbbbb",
|
||||
"bbbbb",
|
||||
"bbbbb",
|
||||
}, {
|
||||
// ICU-22727
|
||||
"cccccc",
|
||||
"cccccc",
|
||||
"cccccc",
|
||||
}, {
|
||||
// ICU-22727
|
||||
"ddddddd",
|
||||
"ddddddd",
|
||||
"ddddddd",
|
||||
}, {
|
||||
// ICU-22727
|
||||
"eeeeeeee",
|
||||
"eeeeeeee",
|
||||
"eeeeeeee",
|
||||
}, {
|
||||
// ICU-22546
|
||||
"und-Zzzz",
|
||||
|
|
|
@ -1925,6 +1925,26 @@ public class ULocaleTest extends CoreTestFmwk {
|
|||
// so "aaaa" is a well-formed unicode_language_id
|
||||
"aaaa",
|
||||
"aaaa",
|
||||
}, {
|
||||
// ICU-22727
|
||||
// unicode_language_subtag = alpha{2,3} | alpha{5,8};
|
||||
// so "bbbbb", "cccccc", "ddddddd", "eeeeeeee" are
|
||||
// well-formed unicode_language_subtag and therefore
|
||||
// well-formed unicode_language_id
|
||||
"bbbbb",
|
||||
"bbbbb",
|
||||
}, {
|
||||
// ICU-22727
|
||||
"cccccc",
|
||||
"cccccc",
|
||||
}, {
|
||||
// ICU-22727
|
||||
"ddddddd",
|
||||
"ddddddd",
|
||||
}, {
|
||||
// ICU-22727
|
||||
"eeeeeeee",
|
||||
"eeeeeeee",
|
||||
}, {
|
||||
// ICU-22546
|
||||
"und-Zzzz",
|
||||
|
|
Loading…
Add table
Reference in a new issue