• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Are the code pages in charsets.jar documented somewhere?

 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Tom Katz
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for info, I appreciate it...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic