]> granicus.if.org Git - icu/commitdiff
ICU-9612 Let 0 in CLDR data mean format number normally with no prefix or suffix.
authorTravis Keep <keep94@gmail.com>
Fri, 28 Sep 2012 00:30:42 +0000 (00:30 +0000)
committerTravis Keep <keep94@gmail.com>
Fri, 28 Sep 2012 00:30:42 +0000 (00:30 +0000)
X-SVN-Rev: 32453

icu4j/main/classes/core/src/com/ibm/icu/text/CompactDecimalDataCache.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/CompactDecimalFormatTest.java

index 3477288d6f5e18934544b49f909d48cd898772a5..0535a91dd34dce1d294cc5490811bf20aa63750b 100644 (file)
@@ -268,10 +268,19 @@ class CompactDecimalDataCache {
                 "' for variant '" +pluralVariant + "' for 10^" + idx +
                 " in " + localeAndStyle(locale, style));
         }
+        String prefix = fixQuotes(template.substring(0, firstIdx));
+        String suffix = fixQuotes(template.substring(lastIdx + 1));
         savePrefixOrSuffix(
-                fixQuotes(template.substring(0, firstIdx)), pluralVariant, idx, result.prefixes);
+                prefix, pluralVariant, idx, result.prefixes);
         savePrefixOrSuffix(
-                fixQuotes(template.substring(lastIdx + 1)), pluralVariant, idx, result.suffixes);
+                suffix, pluralVariant, idx, result.suffixes);
+        
+        // If there is effectively no prefix or suffix, ignore the actual
+        // number of 0's and act as if the number of 0's matches the size
+        // of the number
+        if (prefix.trim().length() == 0 && suffix.trim().length() == 0) {
+          return idx + 1;
+        }
 
         // Calculate number of zeros before decimal point.
         int i = firstIdx + 1;
index cbe9d45a6a47c7fd355d7f062e2f2c157fa325bf..2eff0758efdcb9eda9ea0778f03c6a9f81598ad0 100644 (file)
@@ -124,6 +124,12 @@ public class CompactDecimalFormatTest extends TestFmwk {
             {12712345678901f, "13\u00a0bil."},
             {127123456789012f, "130\u00a0bil."},
     };
+  
+    Object[][] SkTestDataLong = {
+            {1000, "1000"},
+            {1572, "1600"},
+            {5184, "5200"},
+    };
 
     public void TestCharacterIterator() {
         CompactDecimalFormat cdf =
@@ -150,6 +156,15 @@ public class CompactDecimalFormatTest extends TestFmwk {
     public void TestCsShort() {
         checkLocale(ULocale.forLanguageTag("cs"), CompactStyle.SHORT, CsTestDataShort);
     }
+    
+    public void TestSkLong() {
+        // For this Locale, we have
+        // 1000 {
+        //    few{"0"}
+        //    one{"0"}
+        //    other{"0"}
+        checkLocale(ULocale.forLanguageTag("sk"), CompactStyle.LONG, SkTestDataLong);
+    }
 
     public void TestSerbianShort() {
         checkLocale(ULocale.forLanguageTag("sr"), CompactStyle.SHORT, SerbianTestDataShort);