icchanobot
icchanobot

Reputation: 3343

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: 一 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.

Upvotes: 0

Views: 292

Answers (2)

icchanobot
icchanobot

Reputation: 3343

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..

Upvotes: 2

t_motooka
t_motooka

Reputation: 565

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

Upvotes: 0

Related Questions