To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/01d16e0f-3053-8df1-ea48-bd67ae8b99ea%40transactility.com.
Did a small test to see if my vague recollection was valid, no it wasn’t, the bytes match.
Used the old way byte array used for mapping and the new way to encode decode and did not find any differences.
The apostrophe that the OP talks about being a problem does not seem to be a problem based on my ebcdic to ascii and ascii to ebcdic test for ascii 0x27 (apostrophe)
public static void main(String[] args) {
findDiffOldAsciiToEbcdicAndNewAsciiToEbcdic();
findDiffOldEbcdicToAsciiAndNewEbcdicToAscii();
byte[] boaEbcdicOldWay = ISOUtil.asciiToEbcdic("Bank of America's".getBytes(Charset.forName("ISO8859_1")));// old
// way
byte[] boaAscii = ISOUtil.ebcdicToAsciiBytes(boaEbcdicOldWay);// old way
System.out.println(ISOUtil.hexdump(boaAscii));
System.out.println(ISOUtil.hexdump(boaEbcdicOldWay));
Charset EBCDIC = Charset.forName("CP1047");
ByteBuffer ebcNewWay = EBCDIC.encode("Bank of America's");
System.out.println(ISOUtil.hexdump(ebcNewWay.array()));
if (Arrays.equals(ebcNewWay.array(), boaEbcdicOldWay)) {
System.out.println("Old = new");
}
}
private static void findDiffOldEbcdicToAsciiAndNewEbcdicToAscii() {
Charset EBCDIC = Charset.forName("CP1047");
byte[] bArr = new byte[1];
for (int i = 0; i < 256; i++) {
bArr[0] = (byte) i;
String ascOldWay = ISOUtil.ebcdicToAscii(bArr);// uses the old array mapping
String decoded = EBCDIC.decode(ByteBuffer.wrap(bArr))
.toString();// uses the IBM1047
byte[] ascNewWay = decoded.getBytes();
if (ascNewWay[0] != ascOldWay.getBytes()[0]) {
System.out.println(ISOUtil.hexdump(ascOldWay.getBytes()));
System.out.println(ISOUtil.hexdump(ascNewWay));
}
}
}
private static void findDiffOldAsciiToEbcdicAndNewAsciiToEbcdic() {
Charset EBCDIC = Charset.forName("CP1047");
byte[] bArr = new byte[1];
for (int i = 0; i < 256; i++) {
bArr[0] = (byte) i;
byte[] ebcOldWay = ISOUtil.asciiToEbcdic(bArr);
byte[] ebcNewWay = EBCDIC.encode(new String(bArr, Charset.forName("ISO8859_1")))
.array();
if (ebcOldWay[0] != ebcNewWay[0]) {
System.out.println(i);
System.out.println(ISOUtil.hexdump(ebcOldWay));
System.out.println(ISOUtil.hexdump(ebcNewWay));
}
}
}
-chhil