I need to convert raw bytes into various code pages. I tried using the String constructor that takes in a byte and a string representing the code page - e.g 'new String(bytes, "cp037") - and it seemed like some of the characters I got back were different from what's documented for that code page.
Hmmm - no offense, but that sounds kind of backwards. The new String(byte, String) constructor does convert to different encodings - it converts from different encodings of bytes, to a statndard Java String consisting of a sequence of chars whose numeric values are interpreted as Unicode. Strings do not have encodings; bytes have encodings. So if you've got an array of bytes, you need to find out what one encoding was used to generate the bytes in the array. Then you can use that encoding in the new String(byte, String) constructor to get a String. If you then wish to convert that String to bytes, using some other encoding, then you can use getBytes(String) - naming whatever encoding you want.
"I'm not back." - Bill Harding, Twister
Joined: Aug 19, 2002
Thanks for info, I appreciate it...
subject: Are the code pages in charsets.jar documented somewhere?