From 38737268311efb7f5df89ed22dcc1ece823de032 Mon Sep 17 00:00:00 2001 From: Michael Ow Date: Tue, 13 Sep 2011 21:13:14 +0000 Subject: [PATCH] ICU-8815 Sync the ICU canonical name lookup between ICU4C and ICU4J and update alias table X-SVN-Rev: 30652 --- icu4c/source/common/ucnv_io.cpp | 29 ++++++++++++++++++++----- icu4c/source/data/mappings/convrtrs.txt | 2 +- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/icu4c/source/common/ucnv_io.cpp b/icu4c/source/common/ucnv_io.cpp index 36d7f0ebdfd..b846cb0e2f9 100644 --- a/icu4c/source/common/ucnv_io.cpp +++ b/icu4c/source/common/ucnv_io.cpp @@ -749,13 +749,32 @@ findTaggedConverterNum(const char *alias, const char *standard, UErrorCode *pErr U_CFUNC const char * ucnv_io_getConverterName(const char *alias, UBool *containsOption, UErrorCode *pErrorCode) { - if(haveAliasData(pErrorCode) && isAlias(alias, pErrorCode)) { - uint32_t convNum = findConverter(alias, containsOption, pErrorCode); - if (convNum < gMainTable.converterListSize) { - return GET_STRING(gMainTable.converterList[convNum]); + const char *aliasTmp = alias; + int32_t i = 0; + for (i = 0; i < 2; i++) { + if (i == 1) { + /* + * After the first unsuccess converter lookup, check to see if + * the name begins with 'x-'. If it does, strip it off and try + * again. This behaviour is similar to how ICU4J does it. + */ + if (aliasTmp[0] == 'x' || aliasTmp[1] == '-') { + aliasTmp = aliasTmp+2; + } else { + break; + } + } + if(haveAliasData(pErrorCode) && isAlias(aliasTmp, pErrorCode)) { + uint32_t convNum = findConverter(aliasTmp, containsOption, pErrorCode); + if (convNum < gMainTable.converterListSize) { + return GET_STRING(gMainTable.converterList[convNum]); + } + /* else converter not found */ + } else { + break; } - /* else converter not found */ } + return NULL; } diff --git a/icu4c/source/data/mappings/convrtrs.txt b/icu4c/source/data/mappings/convrtrs.txt index 6ce89ee7c3d..7bde6b8313e 100644 --- a/icu4c/source/data/mappings/convrtrs.txt +++ b/icu4c/source/data/mappings/convrtrs.txt @@ -931,7 +931,7 @@ macos-38_2-10.2 { UTR22* } x-mac-romania { MIME* } x-MacRomania { JAVA* } M macos-518-10.2 { UTR22* } x-mac-arabic { MIME* } x-MacArabic { JAVA* } MacArabic { JAVA } macos-1285-10.2 { UTR22* } x-mac-hebrew { MIME* } x-MacHebrew { JAVA* } MacHebrew { JAVA } -ibm-1051_P100-1995 { UTR22* } ibm-1051 { IBM* } hp-roman8 { IANA* } roman8 { IANA } r8 { IANA } csHPRoman8 { IANA } # HP Latin1 +ibm-1051_P100-1995 { UTR22* } ibm-1051 { IBM* } hp-roman8 { IANA* } roman8 { IANA } r8 { IANA } csHPRoman8 { IANA } x-roman8 { JAVA} # HP Latin1 ibm-1276_P100-1995 { UTR22* } ibm-1276 { IBM* } Adobe-Standard-Encoding { IANA* } csAdobeStandardEncoding { IANA } # Different from ISO-Unicode-IBM-1276 (GCSGID: 1276) ibm-1006_P100-1995 { UTR22* } ibm-1006 { IBM* } IBM1006 { JAVA } cp1006 { JAVA* } 1006 { JAVA } x-IBM1006 { JAVA } # Urdu -- 2.40.0