• 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
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ebcdic to ascii

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!


[ October 25, 2004: Message edited by: ryan wayne ]
 
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Here's a sample run of that code.


[ October 26, 2004: Message edited by: peter wooster ]
[ October 26, 2004: Message edited by: peter wooster ]
 
ryan wayne
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
wow, you are the man! i will go try it now
how come you just have lots od 0's instead of the 0x0020, 0x0021, 0x0022, stuff?


thank you so much
[ October 26, 2004: Message edited by: ryan wayne ]
 
ryan wayne
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<EDITED>


gotcha.
I will try it your way.
thanks again man
I'll post what I do
[ October 26, 2004: Message edited by: ryan wayne ]
 
peter wooster
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by ryan wayne:
wow, you are the man! i will go try it now
how come you just have lots od 0's instead of the 0x0020, 0x0021, 0x0022, stuff?


thank you so much

[ October 26, 2004: Message edited by: ryan wayne ]



My version has a complete 256 element mapping between the 2 character sets. The 0's represent those bytes that don't translate. This lets you use simple index to do the translation, instead of having to search like in the version you posted.

You will notice that the last 128 values in the ascii to ebcdic table are all 0, this is because that maps 7 bit ascii. Also the ebcdic to ascii table has no values larger than 127, but they are scattered around, that's because ebcdic is an 8 bit character set.

As I pointed out in my previous message, that version you found is very inefficient, since it does a linear search for each character. An alternative approach would be to build the mappings using a Map.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic