开发者

Android set character encoding

开发者 https://www.devze.com 2023-03-11 08:36 出处:网络
How can I set the encoding of EditText value? I tried this but it does not seem to w开发者_JS百科ork.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消