This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes ebcdic to ascii Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ebcdic to ascii" Watch "ebcdic to ascii" New topic
Author

ebcdic to ascii

ryan wayne
Greenhorn

Joined: Aug 13, 2004
Posts: 9
hello all,

I am receiving a message from an as400 to win box so the message is in ebcdic
I have scoured forever for help and stumbles across this little ditty.
I would like to get an array of bytes and use this but
it is confusing to say the least. can some one show me an example of how this would be used?

thanks alot!

Dun Dagda
Ranch Hand

Joined: Oct 12, 2004
Posts: 54
Perhaps something like:

assuming the above code is in a proper class that has access to your Translate class, something like the above should work. You will then have a string of EBCDIC characters that you can use.

If I have misunderstood what you wanted, or written something stupid, please let me know.

DD


SCJP 1.4<br />SCWCD (in progress)
Dun Dagda
Ranch Hand

Joined: Oct 12, 2004
Posts: 54
Oops, your method returns an int, I forgot to cast it to a byte before putting it in the array like this:


Sorry about that, :roll:
DD
Dun Dagda
Ranch Hand

Joined: Oct 12, 2004
Posts: 54
Anyway, looking more closely at the constructors of the String class in the Java API documentation, String has overloaded constructors that handle byte arrays in a specified charset, so it should be possible to do something like this:

to give you a string translated into EBCDIC, rather than use the Translate class that you found.

DD
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: ebcdic to ascii