开发者

Unescaping a HTML entity of a Japanese character on Blackberry

开发者 https://www.devze.com 2023-03-17 17:03 出处:网络
Basically I am reading in a JSON string which contains a html entity like this: &a开发者_如何学Gomp;#19968;

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();
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消