From e1d0ebb5a4ccfe3c3f5faec1fbdf5e470fd63104 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 19 Apr 2010 15:28:23 -0700 Subject: Fix U_FILE_ACCESS_ERROR RuntimeException in String.getBytes("GB18030"). Bug: 2606807 Change-Id: Ie639ce6380e42e0eed2a7e360504f86a22f1fed8 --- icu/src/main/native/NativeConverter.cpp | 11 ++++++----- 1 file 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); -- cgit v1.1