简体   繁体   中英

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:

byte[] adress= new byte [42];

After I try to displayed to 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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM