A question about charset encoding and ICU4C
I'm running CTS on an android product device(the base code is android 2.3), but the following case failed:
java.io.UnsupportedEncodingException: GB18030 at java.nio.charset.Charset.forNameUEE(Charset.java:317)
at java.nio.charset.Charset.forNameUEE(Charset.java:317)
at java.lang.String.getBytes(String.java:973)
at org.apache.harmony.luni.tests.java.lang.StringBufferTest.test_toString(StringBufferTest.java:101)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
at java.nio.charset.Charset.forName(Charset.java:304)
at java.nio.charset.Charset.forNameUEE(Charset.java:315)
at java.nio.charset.Charset.forNameUEE(Charset.java:317)
at java.lang.String.getBytes(String.java:973)
at org.apache.harmony.luni.tests.java.lang.StringBufferTest.test_toString(StringBufferTest.java:101)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
at java.nio.charset.Charset.forName(Charset.java:304)
at java.nio.charset.Charset.forNameUEE(Charset.java:315)
While I run the same test on Android SDK 2.3.3 emulator, it passed.
Then I compared the source code between android 2.3.3 and my code, nothing different. But I think there must be something different that I have not noticed. I then found this issue is ICU4C related, but ICU4C is very complicated, could any one tell me any clue to track th开发者_JAVA百科is issue? Or how should I proceed to track the issue?
Thanks very much.
This issue still not fixed, I will provide more info hope some one can help.
By some debuging, I find that GB18030 is not supported because GB18030 conventer is not available.
In '/android_root/source/external/icu4c/stubdata/readme.txt', the available converters on Android can be seen( no GB18030 converter):
- cnv/*.cnv are the additional encodings required by Android. These are
- gsm-03.38-2000.cnv
- iso-8859_16-2001.cnv
- docomo-shift_jis-2007.cnv
- kddi-jisx-208-2007.cnv
- kddi-shift_jis-2007.cnv
- softbank-jisx-208-2007.cnv
- softbank-shift_jis-2007.cnv
So this is mainly a build issue, does any one know how to build ICU4C on Android and how to add the gb18030 converter?
I am trying to build ICU4C, but not succeed yet.
I have resolved this question. In fact, this is a build issue, not caused by ICU4C. In the make file, a PRODUCT_LOCALE must be set. Then after built, the CTS can pass.
I have done this with icu version 4.6. Download icu und bind all code from the dir "common" .c and .cpp files in your android.mk. Make a static library and compile it with the following flags inside application.mk.
APP_CPPFLAGS := -DU_COMMON_IMPLEMENTATION -DU_STATIC_IMPLEMENTATION -DU_PALMOS APP_CFLAGS := -DU_COMMON_IMPLEMENTATION -DU_STATIC_IMPLEMENTATION -DU_PALMOS
I found that the platform header file "ppalmos.h" is working and therefore the above preprocessor directive "U_PALMOS".
Makusi
精彩评论