Two Laptop Bag
The moose likes Java in General and the fly likes Need help with Charset class issue ... :-) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Need help with Charset class issue ... :-)" Watch "Need help with Charset class issue ... :-)" New topic

Need help with Charset class issue ... :-)

Dominic Steng�rd
Ranch Hand

Joined: Feb 05, 2001
Posts: 186
Hi JavaGurus!

I am trying to convert two characters in the Big5 character set, 0xA2CF and 0xa55f that correspond to the characters A and 北, to the equivalent characters but in the Unicode character set.

The code is:

The output in the DOS prompt is:

Not the two characters A and 北, encoded in Unicode, that I had expected. There is not even two ?? but one ? ... meaning the data is being interpreted as one character.

What am I doing wrong?
Any help is hugely appreciated.
Thanks in advance! :-)

Best regards

Dominic Steng�rd<br />Sun Certified Java 2 Programmer
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

No, you're on the wrong track entirely.Okay, enough of that. The main point is that there's no such thing as a "Big5 character" in Java. All characters in Java are Unicode characters. It is possible to encode Java characters as a stream (or array) of bytes using Big5, and it's possible to decode those bytes back into Unicode characters using Big5 as well. Perhaps something like this:
I agree. Here's the link:
subject: Need help with Charset class issue ... :-)
It's not a secret anymore!