sorry I have posted twice, please ignore this message

On Aug 14, 10:36 am, myopc <[email protected]> wrote:
> hi, all
>    I found a strange charset encoding bug of dalvik VM. please see the
> following code:
>
>  public class CharsetMain extends Activity {
>  private final static String LOG_TAG = "zzw";
>
>  final String s123="1我2"; // at least one none-ascii
>  final String sabc="abcdef";
>
> �...@override
>  public void onCreate(Bundle savedInstanceState) {
>   super.onCreate(savedInstanceState);
>   Log.d(LOG_TAG, sabc); // ok
>
>   // set charset input to sabc
>   sabc.getBytes();
>
>   // fill charset input with s123
>   Charset charset = java.nio.charset.Charset.forName("UTF-8");
>   charset.encode(s123);
>
>   Log.d(LOG_TAG, sabc);  // bad
>   Log.d(LOG_TAG, "abcdef"); // bad
>   finish();
>  }
>
> }
>
> stirng s123 contains a Chinese character, after run, string sabc will
> be filled with s123, the last 2 log will give bad result.
>
> I found the error is at com.ibm.icu4jni.charset.CharsetEncoderICU,
> method getArray (line 314), here it directly save the internal buffer
> of a input string or copy input string to its saved buffer, if 2
> consequent calls are just the 2 conditions, the later will copy the
> string to the first saved buffer.
>
> I am not sure it's a bug, but it causes the Email program runs
> abnormally with Chinese local.
>
> your comments are greatly appreciated, thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to