QUOTE(NickDMax @ 3 Sep, 2008 - 02:25 PM)

So I have to write some data files that use EBCDIC and I am excited!!!
Whatever turns you on
QUOTE
I have never actually used EBCDIC it is just one of these oddities that I just have never had a chance to use (since I don't do much mainframe work).
Probably that it is still used in the States... all othe languages have accented characters so I guess you will not found EBCDIC used anywhere else... it likes the old AM/PM concept that you will never find on any airline/train/invoice ticket anywhere else in the world
Anyway... My first though twas a hash table, but that turns out to be kind of ugly:
CODE
static {
Hashtable<Byte, Byte> ASCII2EBCDIC = new Hashtable<Byte, Byte>(256);
ASCII2EBCDIC.put(Byte.valueOf((byte)0x00), Byte.valueOf((byte)0x00));
ASCII2EBCDIC.put(Byte.valueOf((byte)0x01), Byte.valueOf((byte)0x01));
ASCII2EBCDIC.put(Byte.valueOf((byte)0x02), Byte.valueOf((byte)0x02));
ASCII2EBCDIC.put(Byte.valueOf((byte)0x03), Byte.valueOf((byte)0x03));
ASCII2EBCDIC.put(Byte.valueOf((byte)0x04), Byte.valueOf((byte)0x04));
}
Forget hastable for that, you are using a Cadillac to deliver a pizza
Just build an Array of equivalent characters indexed by the ASCII code will be a lot more efficient
At the limit, if you want to code, write an algorith to build the array that you will run only once at the object creation
This post has been edited by pbl: 3 Sep, 2008 - 03:57 PM