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?
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.