Java convert unicode code point to string -


how can utf-8 value =d0=93=d0=b0=d0=b7=d0=b5=d1=82=d0=b0 converted in java?

i have tried like:

character.tocodepoint((char)(integer.parseint("d0", 16)),(char)(integer.parseint("93", 16)); 

but not convert valid code point.

that string encoding of bytes in hex, best way decode string byte[], call new string(bytes, standardcharsets.utf_8).

update

here more direct version of decoding string, provided "sstan" in answer. of course both versions good, use whichever makes more comfortable, or write own version.

string src = "=d0=93=d0=b0=d0=b7=d0=b5=d1=82=d0=b0";  assert src.length() % 3 == 0; byte[] bytes = new byte[src.length() / 3]; (int = 0, j = 0; < bytes.length; i++, j+=3) {     assert src.charat(j) == '=';     bytes[i] = (byte)(character.digit(src.charat(j + 1), 16) << 4 |                       character.digit(src.charat(j + 2), 16)); } string str = new string(bytes, standardcharsets.utf_8);  system.out.println(str); 

output

Газета 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -