diff options
author | Elliott Hughes <enh@google.com> | 2010-04-19 15:28:23 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2010-04-19 15:28:23 -0700 |
commit | e1d0ebb5a4ccfe3c3f5faec1fbdf5e470fd63104 (patch) | |
tree | ea6a26015ef9ae35358b029084e882e73705484b | |
parent | 0fa251a6abd62d73a1a3d1ca74ee0bfc55050d90 (diff) | |
download | libcore-e1d0ebb5a4ccfe3c3f5faec1fbdf5e470fd63104.zip libcore-e1d0ebb5a4ccfe3c3f5faec1fbdf5e470fd63104.tar.gz libcore-e1d0ebb5a4ccfe3c3f5faec1fbdf5e470fd63104.tar.bz2 |
Fix U_FILE_ACCESS_ERROR RuntimeException in String.getBytes("GB18030").
Bug: 2606807
Change-Id: Ie639ce6380e42e0eed2a7e360504f86a22f1fed8
-rw-r--r-- | icu/src/main/native/NativeConverter.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/icu/src/main/native/NativeConverter.cpp b/icu/src/main/native/NativeConverter.cpp index 8cc6d15..3f5a186 100644 --- a/icu/src/main/native/NativeConverter.cpp +++ b/icu/src/main/native/NativeConverter.cpp @@ -960,13 +960,14 @@ static jobject charsetForName(JNIEnv* env, jclass, jstring charsetName) { } // Check that this charset is supported. - UErrorCode errorCode = U_ZERO_ERROR; - UConverter* conv = ucnv_open(icuCanonicalName, &errorCode); - icu4jni_error(env, errorCode); - closeConverter(env, NULL, (jlong) conv); - if (env->ExceptionOccurred()) { + // ICU doesn't offer any "isSupported", so we just open and immediately close. + // We ignore the UErrorCode because ucnv_open returning NULL is all the information we need. + UErrorCode dummy = U_ZERO_ERROR; + UConverter* conv = ucnv_open(icuCanonicalName, &dummy); + if (conv == NULL) { return NULL; } + ucnv_close(conv); // Get the aliases for this charset. jobjectArray aliases = getAliases(env, icuCanonicalName); |