Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何设置 EditText 值的编码?
我试过这个,但它似乎不起作用。
String test = new String(myField.getText().toString().getBytes(), "Cp1251");
接收方仍有无效值。
字符串始终在内部(在 String 类中)存储为 unicode。
您应该在将字符串转换为字节并发送数据时指定编码。
也就是说,在字符串上调用getBytes(String encoding),并将生成的字节数组发送到接收方。