]> granicus.if.org Git - icu/commitdiff
ICU-8488 Use explicit locale in String#toLowerCase / #toUpperCase.
authorYoshito Umaoka <y.umaoka@gmail.com>
Fri, 27 May 2011 19:25:11 +0000 (19:25 +0000)
committerYoshito Umaoka <y.umaoka@gmail.com>
Fri, 27 May 2011 19:25:11 +0000 (19:25 +0000)
X-SVN-Rev: 30156

icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetMBCS.java
icu4j/main/classes/core/src/com/ibm/icu/impl/UCharacterName.java
icu4j/main/classes/core/src/com/ibm/icu/impl/Utility.java
icu4j/main/classes/core/src/com/ibm/icu/impl/ZoneMeta.java
icu4j/main/classes/core/src/com/ibm/icu/lang/UCharacter.java
icu4j/main/classes/core/src/com/ibm/icu/util/Calendar.java
icu4j/main/classes/core/src/com/ibm/icu/util/Currency.java
icu4j/main/classes/translit/src/com/ibm/icu/text/TransliteratorRegistry.java

index d61028e142ff7f9d9023b08ce0117d80d97e9b35..a5f3f7333b423b659c7798849520400531b41370 100644 (file)
@@ -19,6 +19,7 @@ import java.nio.IntBuffer;
 import java.nio.charset.CharsetDecoder;
 import java.nio.charset.CharsetEncoder;
 import java.nio.charset.CoderResult;
+import java.util.Locale;
 
 import com.ibm.icu.charset.UConverterSharedData.UConverterType;
 import com.ibm.icu.impl.ICUData;
@@ -898,14 +899,15 @@ class CharsetMBCS extends CharsetICU {
             }
         }
 
-        if (icuCanonicalName.toLowerCase().indexOf("gb18030") >= 0) {
+        String lowerCaseName = icuCanonicalName.toLowerCase(Locale.ENGLISH);
+        if (lowerCaseName.indexOf("gb18030") >= 0) {
             /* set a flag for GB 18030 mode, which changes the callback behavior */
             this.options |= MBCS_OPTION_GB18030;
-        } else if (icuCanonicalName.toLowerCase().indexOf("keis") >= 0) {
+        } else if (lowerCaseName.indexOf("keis") >= 0) {
             this.options |= MBCS_OPTION_KEIS;
-        } else if (icuCanonicalName.toLowerCase().indexOf("jef") >= 0) {
+        } else if (lowerCaseName.indexOf("jef") >= 0) {
             this.options |= MBCS_OPTION_JEF;
-        } else if (icuCanonicalName.toLowerCase().indexOf("jips") >= 0) {
+        } else if (lowerCaseName.indexOf("jips") >= 0) {
             this.options |= MBCS_OPTION_JIPS;
         }
 
index 340cad2fec8f48efa6986d1f355d3d10c585ac4a..c555978f8c942aa5177d2c4660358c16ca6c4669 100644 (file)
@@ -1,6 +1,6 @@
 /**
 *******************************************************************************
-* Copyright (C) 1996-2010, International Business Machines Corporation and    *
+* Copyright (C) 1996-2011, International Business Machines Corporation and    *
 * others. All Rights Reserved.                                                *
 *******************************************************************************
 */
@@ -9,6 +9,7 @@ package com.ibm.icu.impl;
 import java.io.BufferedInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Locale;
 import java.util.MissingResourceException;
 
 import com.ibm.icu.lang.UCharacter;
@@ -114,12 +115,12 @@ public final class UCharacterName
         }
 
         // try extended names first
-        int result = getExtendedChar(name.toLowerCase(), choice);
+        int result = getExtendedChar(name.toLowerCase(Locale.ENGLISH), choice);
         if (result >= -1) {
             return result;
         }
 
-        String upperCaseName = name.toUpperCase();
+        String upperCaseName = name.toUpperCase(Locale.ENGLISH);
         // try algorithmic names first, if fails then try group names
         // int result = getAlgorithmChar(choice, uppercasename);
 
@@ -382,7 +383,7 @@ public final class UCharacterName
                 m_utilStringBuffer_.append('<');
                 m_utilStringBuffer_.append(result);
                 m_utilStringBuffer_.append('-');
-                String chStr = Integer.toHexString(ch).toUpperCase();
+                String chStr = Integer.toHexString(ch).toUpperCase(Locale.ENGLISH);
                 int zeros = 4 - chStr.length();
                 while (zeros > 0) {
                     m_utilStringBuffer_.append('0');
index 31085bc0e7fe6ca7ea32e49f9b5436a96952e0d1..df5192aa1b2e565f6c357992550207b9c39e0d4c 100644 (file)
@@ -8,6 +8,7 @@ package com.ibm.icu.impl;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Locale;
 import java.util.regex.Pattern;
 
 import com.ibm.icu.lang.UCharacter;
@@ -964,7 +965,7 @@ public final class Utility {
         if (negative) {
             i = -i;
         }
-        String result = Long.toString(i, 16).toUpperCase();
+        String result = Long.toString(i, 16).toUpperCase(Locale.ENGLISH);
         if (result.length() < places) {
             result = "0000000000000000".substring(result.length(),places) + result;
         }
index af5af2ca5db50d96eaae9ad7cc70d228bdd7ecdf..b518a60b44f6cebd33cd4ccc7d3bbda0add1515a 100644 (file)
@@ -175,7 +175,7 @@ public final class ZoneMeta {
         }
 
         if (region != null) {
-            region = region.toUpperCase(Locale.US);
+            region = region.toUpperCase(Locale.ENGLISH);
         }
 
         // Filter by region/rawOffset
@@ -560,7 +560,7 @@ public final class ZoneMeta {
      */
     static boolean parseCustomID(String id, int[] fields) {
         NumberFormat numberFormat = null;
-        String idUppercase = id.toUpperCase();
+        String idUppercase = id.toUpperCase(Locale.ENGLISH);
 
         if (id != null && id.length() > kGMT_ID.length() &&
             idUppercase.startsWith(kGMT_ID)) {
index 97fa46224a0df84faab27a7ee8f97660f1df1ba0..c059b620d5f14b5085b80c316360b352677bbfde 100644 (file)
@@ -2199,7 +2199,7 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection
         private static SoftReference<Map<String, UnicodeBlock>> mref;
 
         private static String trimBlockName(String name) {
-            String upper = name.toUpperCase();
+            String upper = name.toUpperCase(Locale.ENGLISH);
             StringBuilder result = new StringBuilder(upper.length());
             for (int i = 0; i < upper.length(); i++) {
                 char c = upper.charAt(i);
index b734c5f1ec76ab83b713074d57af07ed124541d9..036c83ad044fba5330f1e3dcfeb0e7f2ec93d028 100644 (file)
@@ -1693,7 +1693,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
     private static int getCalendarTypeForLocale(ULocale l) {
         String s = CalendarUtil.getCalendarType(l);
         if (s != null) {
-            s = s.toLowerCase();
+            s = s.toLowerCase(Locale.ENGLISH);
             for (int i = 0; i < calTypes.length; ++i) {
                 if (s.equals(calTypes[i])) {
                     return i;
index 90da21262f7aa863e3f5bfbd75c308c20a366437..c612aa1a0df13a056616186b2823d26e0d63469f 100644 (file)
@@ -219,7 +219,7 @@ public class Currency extends MeasureUnit implements Serializable {
             throw new IllegalArgumentException(
                     "The input currency code is not 3-letter alphabetic code.");
         }
-        return new Currency(theISOCode.toUpperCase(Locale.US));
+        return new Currency(theISOCode.toUpperCase(Locale.ENGLISH));
     }
 
     private static boolean isAlpha3Code(String code) {
index 6a68e23ab0176d91527cd95311de4f5f3319c07b..48333b5ec224fa01084cb986223049b334bfa0ae 100644 (file)
@@ -1,6 +1,6 @@
 /*
 **********************************************************************
-*   Copyright (c) 2001-2010, International Business Machines
+*   Copyright (c) 2001-2011, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 **********************************************************************
 *   Date        Name        Description
@@ -679,7 +679,7 @@ class TransliteratorRegistry {
             } else {
                 tag.append("Transliterate");
             }
-            tag.append(specToFind.get().toUpperCase());
+            tag.append(specToFind.get().toUpperCase(Locale.ENGLISH));
 
             try {
                 // The Transliterate*_xxx resource is an array of