Android set character encoding
How can I set the encoding of EditText value?
I tried this but it does not seem to w开发者_JS百科ork.
String test = new String(myField.getText().toString().getBytes(), "Cp1251");
The receiver still has invalid value.
A string is always internally (in the String class) stored as unicode.
You should specify the encoding when you convert the string to bytes, and are sending the data.
That is, invoke getBytes(String encoding) on the string, and send the resulting byte array to the receiver.
精彩评论