]> granicus.if.org Git - icu/commitdiff
ICU-8815 Sync the ICU canonical name lookup between ICU4C and ICU4J and update alias...
authorMichael Ow <mow@svn.icu-project.org>
Tue, 13 Sep 2011 21:13:14 +0000 (21:13 +0000)
committerMichael Ow <mow@svn.icu-project.org>
Tue, 13 Sep 2011 21:13:14 +0000 (21:13 +0000)
X-SVN-Rev: 30652

icu4c/source/common/ucnv_io.cpp
icu4c/source/data/mappings/convrtrs.txt

index 36d7f0ebdfd73ec2da6719d9fbea17e521522c11..b846cb0e2f91bd3a06d58c6cb603691a902cdebb 100644 (file)
@@ -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;
 }
 
index 6ce89ee7c3dd35932b22b361b2a9c9c1a1e4d960..7bde6b8313e16b37fa806662cc389ef3d2b2fa61 100644 (file)
@@ -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