Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Which jar do I need for EBCDIC character encoding?

 
Tom Katz
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to convert, on-the-fly, a bytestream to different character sets (ASCII and EBCDIC), but my list of availableCharsets does not include any EBCDIC code pages? I"m using jdk1.4 - Is what I'm doing possible with this version?

thanks,
Tom
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know how to translate one to another with character sets, but you can do it easily using each character as an int index into a table:

http://www.room42.com/store/computer_center/java_translate.shtml
http://www.google.com/search?q=ascii+ebcdic+translate+java
 
Tom Katz
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
THanks, I may try that. For now, I think I found what I wanted by using the String constructor
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool. Can you show a little more of how that works?
 
Tom Katz
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Turns out, we have a customer who was getting an unsupportedCodePage(?) exception when doing this kind of java conversion, so I may have to do some manual conversion program anyway.

But the way the Sring conversion works is to pass in a byte[], along with a charset constant, e.g. Cp500 ISO8859_1, Cp037, etc. And you get a String encoded in that charset:



To get the bytes in a certain charset FROM a string you simply call:



This seems to work great for me, and I'd be able to use it except for this one customer's problem (most likely they've got some kinda screwed up JRE install), but I sure hope I get to use it, it would save me some time!
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
THanks! Learn somethin every day at the ranch!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!