Unescaping a HTML entity of a Japanese character on Blackberry
Basically I am reading in a JSON string which contains a html entity like this: &a开发者_如何学Gomp;#19968;
And but in my app that is not useful. I need this: 一
(Japanese character for 1)
What is the best way to do this? Both the JSON and my app are using UTF-8
I've parsed out the int
so now I basically have int i = 19968;
I tried casting to a char, converting to hex and then casting to a char. but nothing works..
help.
It turns out it was a simulator issue. I somehow changed simulators.. and assumed the EastAsia simulator would support kanji, but it just drew boxes..
try following code :
int i = 19968;
byte[] bytes = new byte[2];
bytes[0] = (byte)((i >>> 8) & 0x00ff);
bytes[1] = (byte)( i & 0x00ff);
String str = null;
try {
str = new String(bytes, "Unicode");
// System.out.println(str);
}
catch(UnsupportedEncodingException uee) {
uee.printStackTrace();
}
精彩评论