Skip to content

Commit b996255

Browse files
committed
ICU-20575 fix broken default locale mapping for C.UTF-8
- Correct regression in 1afef30 / ICU-20187 - PR#418 incorrectly dropped the mapping from C to en-us-POSIX without handling cases where a codepage was set (such as C.UTF-8). - The “strcmp("C", …)” in uprv_getPOSIXIDForCategory() was intended to detect specific platform behavior, it is not a general mapping. - Add an additional test in uprv_getDefaultLocaleID() for locales that end up as "C" or "POSIX" after removing codepage suffix
1 parent 711e7e0 commit b996255

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

icu4c/source/common/putil.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,6 +1560,10 @@ static const char *uprv_getPOSIXIDForCategory(int category)
15601560
{
15611561
/* Nothing worked. Give it a nice POSIX default value. */
15621562
posixID = "en_US_POSIX";
1563+
// Note: this test will not catch 'C.UTF-8',
1564+
// that will be handled in uprv_getDefaultLocaleID().
1565+
// Leave this mapping here for the uprv_getPOSIXIDForDefaultCodepage()
1566+
// callers.
15631567
}
15641568
return posixID;
15651569
}
@@ -1681,6 +1685,11 @@ The leftmost codepage (.xxx) wins.
16811685
* Many of the other locales using ISO codes will be handled by the
16821686
* canonicalization functions in uloc_getDefault.
16831687
*/
1688+
} else if ((uprv_strcmp("C", correctedPOSIXLocale) == 0) // no @ variant
1689+
|| (uprv_strcmp("POSIX", correctedPOSIXLocale) == 0)) {
1690+
// Raw input was C.* or POSIX.*, Give it a nice POSIX default value.
1691+
// (The "C"/"POSIX" case is handled in uprv_getPOSIXIDForCategory())
1692+
uprv_strcpy(correctedPOSIXLocale, "en_US_POSIX");
16841693
}
16851694

16861695
if (gCorrectedPOSIXLocale == nullptr) {

0 commit comments

Comments
 (0)