Encode text bitmap in EBCDIC with forceStringEncoding=true #13

This commit is contained in:
Enrique Zamudio
2013-05-13 23:13:44 -05:00
parent 1787dfb0d5
commit 1ce67c621c
2 changed files with 16 additions and 2 deletions
@@ -373,6 +373,11 @@ public class IsoMessage {
}
}
} else {
ByteArrayOutputStream bout2 = null;
if (forceStringEncoding) {
bout2 = bout;
bout = new ByteArrayOutputStream();
}
int pos = 0;
int lim = bs.size() / 4;
for (int i = 0; i < lim; i++) {
@@ -387,6 +392,15 @@ public class IsoMessage {
nibble |= 1;
bout.write(HEX[nibble]);
}
if (forceStringEncoding) {
final String _hb = new String(bout.toByteArray());
bout = bout2;
try {
bout.write(_hb.getBytes(encoding));
} catch (IOException ignore) {
//never happen
}
}
}
//Fields
@@ -328,7 +328,7 @@ public class MessageFactory<T extends IsoMessage> {
try {
final byte[] bitmapBuffer;
if (forceStringEncoding) {
byte[] _bb = HexCodec.hexDecode(new String(buf, isoHeaderLength+4, 16, encoding));
byte[] _bb = new String(buf, isoHeaderLength+4, 16, encoding).getBytes();
bitmapBuffer = new byte[36+isoHeaderLength];
System.arraycopy(_bb, 0, bitmapBuffer, 4+isoHeaderLength, 16);
} else {
@@ -358,7 +358,7 @@ public class MessageFactory<T extends IsoMessage> {
throw new ParseException("Insufficient length for secondary bitmap", minlength);
}
if (forceStringEncoding) {
byte[] _bb = HexCodec.hexDecode(new String(buf, isoHeaderLength+4, 16, encoding));
byte[] _bb = new String(buf, isoHeaderLength+4, 16, encoding).getBytes();
System.arraycopy(_bb, 0, bitmapBuffer, 20+isoHeaderLength, 16);
}
for (int i = isoHeaderLength + 20; i < isoHeaderLength + 36; i++) {