unicode help

I have what I think is a simple problem that I can't seem to figure out. I am working with Korean unicode which requires me to use a decimal formula to calculate the correct symbol in my program. The problem is that once I get this decimal I have not been able to get it back into a format that the computer is happy with. Here's my code.

private String toHex(int d) {

String digits = "0123456789ABCDEF";

if (d=0) return "";

String hex = "";

while (d>0)

int digit = d % 16;

hex = digits.charAt(digit) + hex;

d = d / 16;

}

return hex;

}

So I give it an int of 44032 and this gives me a string with a value of AC00.

What I want it to do is to give me \uAC00. So I'd like to change the return variable to char

private char toHex(int d)

...

and have it give me the unicode back.

I have tried to concatenate a string together with something like this

String unicode = ("\u" + hex):

but the compiler doesn't like the \u without the HEX characters

so I tried this

String unicode = ("\\u" + hex);

so now the string is correct but it is read as a string vice a char :(

Any help would be appreciated.

[1239 byte] By [DGordona] at [2007-11-27 11:59:52]
# 1

If you already have the correct value for the Unicode code point as an int, the only conversion you need to do is to cast it to a char: char ch = (char) d;

uncle_alicea at 2007-7-29 19:28:07 > top of Java-index,Java Essentials,New To Java...
# 2

Thank you :)

I new it was a simple problem, but I couldn't figure it out.

Works like a charm

Dan

DGordona at 2007-7-29 19:28:07 > top of Java-index,Java Essentials,New To Java...