From 4e96e53a079556044276e3a16d0154df51caea02 Mon Sep 17 00:00:00 2001 From: Yoshito Umaoka Date: Thu, 13 Oct 2016 18:57:12 +0000 Subject: [PATCH] ICU-12801 Fixing TestLocaleStructure failure triggered by the new locale 'ckb'. X-SVN-Rev: 39447 --- icu4c/source/common/locmap.c | 60 +++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/icu4c/source/common/locmap.c b/icu4c/source/common/locmap.c index 67a5f0d38a1..c03cd5cf969 100644 --- a/icu4c/source/common/locmap.c +++ b/icu4c/source/common/locmap.c @@ -215,11 +215,8 @@ ILCID_POSIX_ELEMENT_ARRAY(0x045c, chr,chr_US) ILCID_POSIX_SUBTABLE(ckb) { {0x92, "ckb"}, - {0x92, "ku"}, {0x7c92, "ckb_Arab"}, - {0x7c92, "ku_Arab"}, - {0x0492, "ckb_Arab_IQ"}, - {0x0492, "ku_Arab_IQ"} + {0x0492, "ckb_Arab_IQ"} }; /* Declared as cs_CZ to get around compiler errors on z/OS, which defines cs as a function */ @@ -1021,33 +1018,40 @@ uprv_convertToPosix(uint32_t hostid, char *posixID, int32_t posixIDCapacity, UEr const char *pPosixID = NULL; #ifdef USE_WINDOWS_LOCALE_API - int32_t tmpLen = 0; - char locName[157]; /* ULOC_FULLNAME_CAPACITY */ + // Note: Windows primary lang ID 0x92 in LCID is used for Central Kurdish and + // GetLocaleInfo() maps such LCID to "ku". However, CLDR uses "ku" for + // Northern Kurdish and "ckb" for Central Kurdish. For this reason, we cannot + // use the Windows API to resolve locale ID for this specific case. + if (hostid & 0x3FF != 0x92) { + int32_t tmpLen = 0; + char locName[157]; /* ULOC_FULLNAME_CAPACITY */ - tmpLen = GetLocaleInfoA(hostid, LOCALE_SNAME, (LPSTR)locName, UPRV_LENGTHOF(locName)); - if (tmpLen > 1) { - /* Windows locale name may contain sorting variant, such as "es-ES_tradnl". - In such case, we need special mapping data found in the hardcoded table - in this source file. */ - char *p = uprv_strchr(locName, '_'); - if (p) { - /* Keep the base locale, without variant */ - *p = 0; - tmpLen = uprv_strlen(locName); - } else { - /* No hardcoded table lookup necessary */ - bLookup = FALSE; - } - /* Change the tag separator from '-' to '_' */ - p = locName; - while (*p) { - if (*p == '-') { - *p = '_'; + tmpLen = GetLocaleInfoA(hostid, LOCALE_SNAME, (LPSTR)locName, UPRV_LENGTHOF(locName)); + if (tmpLen > 1) { + /* Windows locale name may contain sorting variant, such as "es-ES_tradnl". + In such case, we need special mapping data found in the hardcoded table + in this source file. */ + char *p = uprv_strchr(locName, '_'); + if (p) { + /* Keep the base locale, without variant */ + *p = 0; + tmpLen = uprv_strlen(locName); } - p++; + else { + /* No hardcoded table lookup necessary */ + bLookup = FALSE; + } + /* Change the tag separator from '-' to '_' */ + p = locName; + while (*p) { + if (*p == '-') { + *p = '_'; + } + p++; + } + FIX_LANGUAGE_ID_TAG(locName, tmpLen); + pPosixID = locName; } - FIX_LANGUAGE_ID_TAG(locName, tmpLen); - pPosixID = locName; } #endif if (bLookup) {