Skip to content

Commit

Permalink
ICU-22765 fix uloc_addLikelySubtags on "und@x=private"
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankYFTang committed Oct 16, 2024
1 parent ca9fcca commit 1dcb4bc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion icu4c/source/common/loclikelysubtags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ LSR LikelySubtags::makeMaximizedLsrFrom(const Locale &locale,
return {};
}
const char *name = locale.getName();
if (uprv_isAtSign(name[0]) && name[1] == 'x' && name[2] == '=') { // name.startsWith("@x=")
if (!returnInputIfUnmatch && uprv_isAtSign(name[0]) && name[1] == 'x' && name[2] == '=') { // name.startsWith("@x=")
// Private use language tag x-subtag-subtag... which CLDR changes to
// und-x-subtag-subtag...
return LSR(name, "", "", LSR::EXPLICIT_LSR);
Expand Down
7 changes: 7 additions & 0 deletions icu4c/source/test/cintltst/cloctst.c
Original file line number Diff line number Diff line change
Expand Up @@ -3924,6 +3924,13 @@ const char* const basic_maximize_data[][2] = {
// ICU-22545 & ICU-22742
"ru_XC",
"ru_Cyrl_XC"
}, {
// ICU-22765
"und@x=private",
"en_Latn_US@x=private",
}, {
"th@x=private",
"th_Thai_TH@x=private",
}
};

Expand Down
9 changes: 9 additions & 0 deletions icu4c/source/test/intltest/loctest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4124,6 +4124,15 @@ LocaleTest::TestAddLikelyAndMinimizeSubtags() {
"en_PSCRACK",
"en_Latn_US_PSCRACK",
"en__PSCRACK"
}, {
// ICU-22765
"th@x=private",
"th_Thai_TH@x=private",
"th@x=private",
}, {
"und@x=private",
"en_Latn_US@x=private",
"en@x=private",
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4162,7 +4162,15 @@ else if (!res.toString().equals(exp)) {
"und_US",
"en_Latn_US",
"en"
}
}, {
"th@x=private",
"th_Thai_TH@x=private",
"th@x=private",
}, {
"und@x=private",
"en_Latn_US@x=private",
"en@x=private",
}
};

for (int i = 0; i < full_data.length; i++) {
Expand Down

0 comments on commit 1dcb4bc

Please sign in to comment.