Dear all, Can anyone point me in direction of java classes that handle unicode strings ? Basically I need to convert a unicode string like for example <FEFF004100420043> into a human readable sequence of chars. This string will translate to <ABC>. The particular problem I have is to convert japanese unicode strings into japanese chars. Thanks, Steve Matthews
Since all Java Strings use Unicode internally, I'd call this a hexadecimal representation of Unicode values. Perhaps the simplest approach is to break it up into groups of 4 chars (each representing 1 char, e.g. "0041" = 'A'). Then use Integer.parseInt(str, 16) to convert a 4-char hexadecimal String str into an equivalent integer, and then cast it to single char. Collect the newly-parsed chars in a StringBuffer or something.
This is an excellent book in Internationaliztion (I18N), it should have some good informatoin/ideas about dealing with Japanese characters and other things you need ot be aware of (double byte stuff) Java Internationalization (O'Reilly) by Deitsch and Czarnecki
What do you mean by "to convert a unicode string like for example <FEFF004100420043> into a human readable sequence of chars"? Is FEFF004100420043 a symbolic representation of your string or hexadecimal? If it's simply a Unicode string, then you need a font that is capable of representing used set of characters (Japanese in your case). If I understand right, parsing you will need if FEFF004100420043 is, say, ASCII-coded string representing a Unicode string? Parsing "Unicode strings" can be tricky. FEFF for example is not a Unicode character, it is the Byte Order Mark, serving to indicate endianness. You can safely drop it. And are you sure it's always two bytes per character?