diff options
author | Elliott Hughes <enh@google.com> | 2010-03-29 17:39:51 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2010-03-29 17:39:51 -0700 |
commit | 90aa512eb7b126deb8d752b7474c30d3f73507b2 (patch) | |
tree | 33b118d24b080c7432de64d6ca3315a3a04ed953 /icu/src/main | |
parent | abd91e389e4462208eb004b38d378f67d9676ec1 (diff) | |
download | libcore-90aa512eb7b126deb8d752b7474c30d3f73507b2.zip libcore-90aa512eb7b126deb8d752b7474c30d3f73507b2.tar.gz libcore-90aa512eb7b126deb8d752b7474c30d3f73507b2.tar.bz2 |
Add Java 6's exponent separator to DecimalFormatSymbols.
Bug: 2497395
Change-Id: Ic552fa828649bae882e508a62a44073d1038b5c0
Diffstat (limited to 'icu/src/main')
-rw-r--r-- | icu/src/main/java/com/ibm/icu4jni/util/LocaleData.java | 5 | ||||
-rw-r--r-- | icu/src/main/native/Resources.cpp | 33 |
2 files changed, 21 insertions, 17 deletions
diff --git a/icu/src/main/java/com/ibm/icu4jni/util/LocaleData.java b/icu/src/main/java/com/ibm/icu4jni/util/LocaleData.java index 109183d..e8572a2 100644 --- a/icu/src/main/java/com/ibm/icu4jni/util/LocaleData.java +++ b/icu/src/main/java/com/ibm/icu4jni/util/LocaleData.java @@ -52,6 +52,7 @@ public final class LocaleData { public String decimalPatternChars; + public String exponentSeparator; public String infinity; public String NaN; @@ -82,6 +83,7 @@ public final class LocaleData { "mediumDateFormat=" + mediumDateFormat + "," + "shortDateFormat=" + shortDateFormat + "," + "decimalPatternChars=" + decimalPatternChars + "," + + "exponentSeparator=" + exponentSeparator + "," + "infinity=" + infinity + "," + "NaN=" + NaN + "," + "currencySymbol=" + currencySymbol + "," + @@ -144,6 +146,9 @@ public final class LocaleData { if (overrides.decimalPatternChars != null) { decimalPatternChars = overrides.decimalPatternChars; } + if (overrides.exponentSeparator != null) { + exponentSeparator = overrides.exponentSeparator; + } if (overrides.NaN != null) { NaN = overrides.NaN; } diff --git a/icu/src/main/native/Resources.cpp b/icu/src/main/native/Resources.cpp index 00bf746..9dbdb3d 100644 --- a/icu/src/main/native/Resources.cpp +++ b/icu/src/main/native/Resources.cpp @@ -514,7 +514,7 @@ static jobjectArray getShortWeekdayNames(JNIEnv* env, UResourceBundle* gregorian static jstring getDecimalPatternChars(JNIEnv* env, UResourceBundle* rootElems) { UErrorCode status = U_ZERO_ERROR; - int zeroL, digitL, decSepL, groupL, listL, percentL, permillL, expL, currSepL, minusL; + int zeroL, digitL, decSepL, groupL, listL, percentL, permillL, currSepL, minusL; const jchar* zero = ures_getStringByIndex(rootElems, 4, &zeroL, &status); const jchar* digit = ures_getStringByIndex(rootElems, 5, &digitL, &status); @@ -523,7 +523,6 @@ static jstring getDecimalPatternChars(JNIEnv* env, UResourceBundle* rootElems) { const jchar* list = ures_getStringByIndex(rootElems, 2, &listL, &status); const jchar* percent = ures_getStringByIndex(rootElems, 3, &percentL, &status); const jchar* permill = ures_getStringByIndex(rootElems, 8, &permillL, &status); - const jchar* exp = ures_getStringByIndex(rootElems, 7, &expL, &status); const jchar* currSep = ures_getStringByIndex(rootElems, 0, &currSepL, &status); const jchar* minus = ures_getStringByIndex(rootElems, 6, &minusL, &status); @@ -531,21 +530,18 @@ static jstring getDecimalPatternChars(JNIEnv* env, UResourceBundle* rootElems) { return NULL; } - jchar patternChars[11]; - patternChars[0] = 0; - - u_strncat(patternChars, zero, 1); - u_strncat(patternChars, digit, 1); - u_strncat(patternChars, decSep, 1); - u_strncat(patternChars, group, 1); - u_strncat(patternChars, list, 1); - u_strncat(patternChars, percent, 1); - u_strncat(patternChars, permill, 1); - u_strncat(patternChars, exp, 1); - u_strncat(patternChars, currSep, 1); - u_strncat(patternChars, minus, 1); - - return env->NewString(patternChars, 10); + jchar patternChars[] = { + zero[0], + digit[0], + decSep[0], + group[0], + list[0], + percent[0], + permill[0], + currSep[0], + minus[0], + }; + return env->NewString(patternChars, sizeof(patternChars)); } static jstring getIntCurrencyCode(JNIEnv* env, jstring locale) { @@ -600,6 +596,8 @@ static void setStringField(JNIEnv* env, jobject obj, const char* fieldName, URes const UChar* chars = ures_getStringByIndex(bundle, index, &charCount, &status); if (U_SUCCESS(status)) { setStringField(env, obj, fieldName, env->NewString(chars, charCount)); + } else { + LOGE("Error setting field %s from ICU resource: %s", fieldName, u_errorName(status)); } } @@ -656,6 +654,7 @@ static jboolean initLocaleDataImpl(JNIEnv* env, jclass clazz, jstring locale, jo ScopedResourceBundle numberElements(ures_getByKey(root.get(), "NumberElements", NULL, &status)); if (U_SUCCESS(status) && ures_getSize(numberElements.get()) >= 11) { setStringField(env, localeData, "decimalPatternChars", getDecimalPatternChars(env, numberElements.get())); + setStringField(env, localeData, "exponentSeparator", numberElements.get(), 7); setStringField(env, localeData, "infinity", numberElements.get(), 9); setStringField(env, localeData, "NaN", numberElements.get(), 10); } |