[英]Android byte to string charset
I have a problem with the charset convertion: 我对字符集转换有疑问:
I have got messages from udp server and I get the data like this: 我收到了来自udp服务器的消息,并且得到了如下数据:
byte[] adress= new byte [42];
After I try to displayed to textview : 在我尝试显示到textview之后:
String str_adress= new String(adress,"UTF-8");
Instead of "ő" I got just "?" 我得到的不是“原来的”,而是“?”。
How can I solve that? 我该如何解决?
The UTF-8 bytes for ő
are c5 91
. ő
的UTF-8字节为c5 91
。
As 如
Log.v(TAG, new String(new byte[] { (byte) 0xc5, (byte) 0x91 }, "UTF-8"));
outputs 输出
ő
I think you looked in the wrong place for the problem. 我认为您在错误的地方找到了问题。 It's coming from somewhere else, like reading the udp message maybe.
它来自其他地方,例如可能阅读udp消息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.