From 17717d9c7f2ecac68c2477b63fdb4ee64273ed11 Mon Sep 17 00:00:00 2001 From: Yoshito Umaoka Date: Tue, 17 Apr 2007 03:10:13 +0000 Subject: [PATCH] ICU-5683 Merging the fix for Chinese alias bundle resolution issue reproduced in 3.6 stream and its test code into trunk, although the issue is not reproduced in 3.8 stream. X-SVN-Rev: 21419 --- .../test/format/DateFormatRegressionTest.java | 38 ++++++++++++++++++- .../com/ibm/icu/impl/ICUResourceBundle.java | 2 +- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/icu4j/src/com/ibm/icu/dev/test/format/DateFormatRegressionTest.java b/icu4j/src/com/ibm/icu/dev/test/format/DateFormatRegressionTest.java index 7032bf1c84..b4b00762c5 100755 --- a/icu4j/src/com/ibm/icu/dev/test/format/DateFormatRegressionTest.java +++ b/icu4j/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 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk { } } } + + // 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/icu4j/src/com/ibm/icu/impl/ICUResourceBundle.java b/icu4j/src/com/ibm/icu/impl/ICUResourceBundle.java index 853f2ae71d..875a393bdb 100644 --- a/icu4j/src/com/ibm/icu/impl/ICUResourceBundle.java +++ b/icu4j/src/com/ibm/icu/impl/ICUResourceBundle.java @@ -884,7 +884,7 @@ public class ICUResourceBundle extends UResourceBundle { int type = RES_GET_TYPE(rootResource); if (type == TABLE) { ICUResourceBundleImpl.ResourceTable table = new ICUResourceBundleImpl.ResourceTable(reader, baseName, localeID, loader); - if(table.getSize()==1){ + if(table.getSize()>=1){ // ticket#5683 ICU4J 3.6 data for zh_xx contains an entry other than %%ALIAS UResourceBundle b = table.handleGet(0, null, table); String itemKey = b.getKey();