Skip to content

Commit

Permalink
ICU-20575 fix broken default locale mapping for C.UTF-8
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
srl295 committed Apr 25, 2019
1 parent 711e7e0 commit b996255
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions icu4c/source/common/putil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,10 @@ static const char *uprv_getPOSIXIDForCategory(int category)
{
/* Nothing worked. Give it a nice POSIX default value. */
posixID = "en_US_POSIX";
// Note: this test will not catch 'C.UTF-8',
// that will be handled in uprv_getDefaultLocaleID().
// Leave this mapping here for the uprv_getPOSIXIDForDefaultCodepage()
// callers.
}
return posixID;
}
Expand Down Expand Up @@ -1681,6 +1685,11 @@ The leftmost codepage (.xxx) wins.
* Many of the other locales using ISO codes will be handled by the
* canonicalization functions in uloc_getDefault.
*/
} else if ((uprv_strcmp("C", correctedPOSIXLocale) == 0) // no @ variant
|| (uprv_strcmp("POSIX", correctedPOSIXLocale) == 0)) {
// Raw input was C.* or POSIX.*, Give it a nice POSIX default value.
// (The "C"/"POSIX" case is handled in uprv_getPOSIXIDForCategory())
uprv_strcpy(correctedPOSIXLocale, "en_US_POSIX");
}

if (gCorrectedPOSIXLocale == nullptr) {
Expand Down

0 comments on commit b996255

Please sign in to comment.