Skip to content

Commit 1dcb4bc

Browse files
committed
ICU-22765 fix uloc_addLikelySubtags on "und@x=private"
1 parent ca9fcca commit 1dcb4bc

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

icu4c/source/common/loclikelysubtags.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ LSR LikelySubtags::makeMaximizedLsrFrom(const Locale &locale,
527527
return {};
528528
}
529529
const char *name = locale.getName();
530-
if (uprv_isAtSign(name[0]) && name[1] == 'x' && name[2] == '=') { // name.startsWith("@x=")
530+
if (!returnInputIfUnmatch && uprv_isAtSign(name[0]) && name[1] == 'x' && name[2] == '=') { // name.startsWith("@x=")
531531
// Private use language tag x-subtag-subtag... which CLDR changes to
532532
// und-x-subtag-subtag...
533533
return LSR(name, "", "", LSR::EXPLICIT_LSR);

icu4c/source/test/cintltst/cloctst.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3924,6 +3924,13 @@ const char* const basic_maximize_data[][2] = {
39243924
// ICU-22545 & ICU-22742
39253925
"ru_XC",
39263926
"ru_Cyrl_XC"
3927+
}, {
3928+
// ICU-22765
3929+
"und@x=private",
3930+
"en_Latn_US@x=private",
3931+
}, {
3932+
"th@x=private",
3933+
"th_Thai_TH@x=private",
39273934
}
39283935
};
39293936

icu4c/source/test/intltest/loctest.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4124,6 +4124,15 @@ LocaleTest::TestAddLikelyAndMinimizeSubtags() {
41244124
"en_PSCRACK",
41254125
"en_Latn_US_PSCRACK",
41264126
"en__PSCRACK"
4127+
}, {
4128+
// ICU-22765
4129+
"th@x=private",
4130+
"th_Thai_TH@x=private",
4131+
"th@x=private",
4132+
}, {
4133+
"und@x=private",
4134+
"en_Latn_US@x=private",
4135+
"en@x=private",
41274136
}
41284137
};
41294138

icu4j/main/common_tests/src/test/java/com/ibm/icu/dev/test/util/ULocaleTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4162,7 +4162,15 @@ else if (!res.toString().equals(exp)) {
41624162
"und_US",
41634163
"en_Latn_US",
41644164
"en"
4165-
}
4165+
}, {
4166+
"th@x=private",
4167+
"th_Thai_TH@x=private",
4168+
"th@x=private",
4169+
}, {
4170+
"und@x=private",
4171+
"en_Latn_US@x=private",
4172+
"en@x=private",
4173+
}
41664174
};
41674175

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

0 commit comments

Comments
 (0)