ICU-5683 Quick fix for malformed Chinese locale alias bundle issue
X-SVN-Rev: 21416
diff --git a/src/com/ibm/icu/dev/test/format/DateFormatRegressionTest.java b/src/com/ibm/icu/dev/test/format/DateFormatRegressionTest.java
index 7032bf1..b4b0076 100755
--- a/src/com/ibm/icu/dev/test/format/DateFormatRegressionTest.java
+++ b/src/com/ibm/icu/dev/test/format/DateFormatRegressionTest.java
@@ -1,6 +1,6 @@
/*
*******************************************************************************
- * Copyright (C) 2001-2005, International Business Machines Corporation and *
+ * Copyright (C) 2001-2007, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@@ -961,4 +961,40 @@
}
}
}
+
+ // Ticket#5683
+ // Some ICU4J 3.6 data files contain garbage data which prevent the code to resolve another
+ // bundle as an alias. zh_TW should be equivalent to zh_Hant_TW
+ public void TestT5683() {
+ Locale[] aliasLocales = {
+ new Locale("zh", "CN"),
+ new Locale("zh", "TW"),
+ new Locale("zh", "HK"),
+ new Locale("zh", "SG"),
+ new Locale("zh", "MO")
+ };
+
+ ULocale[] canonicalLocales = {
+ new ULocale("zh_Hans_CN"),
+ new ULocale("zh_Hant_TW"),
+ new ULocale("zh_Hant_HK"),
+ new ULocale("zh_Hans_SG"),
+ new ULocale("zh_Hant_MO")
+ };
+
+ Date d = new Date(0);
+
+ for (int i = 0; i < aliasLocales.length; i++) {
+ DateFormat dfAlias = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, aliasLocales[i]);
+ DateFormat dfCanonical = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, canonicalLocales[i]);
+
+ String sAlias = dfAlias.format(d);
+ String sCanonical = dfCanonical.format(d);
+
+ if (!sAlias.equals(sCanonical)) {
+ errln("Fail: The format result for locale " + aliasLocales[i] + " is different from the result for locale " + canonicalLocales[i]
+ + ": " + sAlias + "[" + aliasLocales[i] + "] / " + sCanonical + "[" + canonicalLocales[i] + "]");
+ }
+ }
+ }
}
diff --git a/src/com/ibm/icu/impl/ICUResourceBundleImpl.java b/src/com/ibm/icu/impl/ICUResourceBundleImpl.java
index 61cf43e..10c433e 100644
--- a/src/com/ibm/icu/impl/ICUResourceBundleImpl.java
+++ b/src/com/ibm/icu/impl/ICUResourceBundleImpl.java
@@ -91,7 +91,7 @@
int type = RES_GET_TYPE(rootResource);
if (type == TABLE) {
ResourceTable table = new ResourceTable(null, rootResource, "", true);
- if(table.size==1){
+ if(table.size>=1){ // ticket#5683 ICU4J 3.6 data for zh_xx contains an entry other than %%ALIAS
ICUResourceBundle b = table.handleGet(0, table);
String itemKey = b.getKey();