diff options
Diffstat (limited to 'thirdparty/icu4c/common/locdispnames.cpp')
-rw-r--r-- | thirdparty/icu4c/common/locdispnames.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/thirdparty/icu4c/common/locdispnames.cpp b/thirdparty/icu4c/common/locdispnames.cpp index 96af3f9aa8..c512a0164c 100644 --- a/thirdparty/icu4c/common/locdispnames.cpp +++ b/thirdparty/icu4c/common/locdispnames.cpp @@ -316,17 +316,29 @@ _getStringOrCopyKey(const char *path, const char *locale, /* see comment about closing rb near "return item;" in _res_getTableStringWithFallback() */ } } else { + bool isLanguageCode = (uprv_strncmp(tableKey, _kLanguages, 9) == 0); /* Language code should not be a number. If it is, set the error code. */ - if (!uprv_strncmp(tableKey, "Languages", 9) && uprv_strtol(itemKey, NULL, 10)) { + if (isLanguageCode && uprv_strtol(itemKey, NULL, 10)) { *pErrorCode = U_MISSING_RESOURCE_ERROR; } else { /* second-level item, use special fallback */ s=uloc_getTableStringWithFallback(path, locale, - tableKey, + tableKey, subTableKey, itemKey, &length, pErrorCode); + if (U_FAILURE(*pErrorCode) && isLanguageCode && itemKey != nullptr) { + // convert itemKey locale code to canonical form and try again, ICU-20870 + *pErrorCode = U_ZERO_ERROR; + Locale canonKey = Locale::createCanonical(itemKey); + s=uloc_getTableStringWithFallback(path, locale, + tableKey, + subTableKey, + canonKey.getName(), + &length, + pErrorCode); + } } } |