hi, all
     I met a strange error of charset encoding, see below 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();
 }
}

string s123 contains a Chinese character, the last 2 log gives a bad
result, the string sabc is filled with string s123.

I found the error is at com.ibm.icu4jni.charset.CharsetEncoderICU,
method getArray, about line 342.
it saves the internal buffer of input string, or just copy the input
string to it saved buffer, if 2 continuous calls are just the 2
conditions, the later will copy the input string to the buffer of 1st
string.

I am not sure it's a bug, but it cases Email program runs abnormally
with Chinese local.

any idea? any comments are 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to