Hi Sean,
Thanks a lot for taking the time to respond to this! That’s great information about how different barcodes have varying levels of support for different character encodings. The barcode being utilized by the old legacy system is a DataMatrix code.
I’m relatively sure that the DataMatrix barcode contains EBCDIC characters, but only insofar as the developers on the external system have stated as much. At the very least, the barcode data is able to be decoded by the ZXing reader, so the data is ‘valid’ in terms of the barcode contents.
Here’s an image of a problematic barcode (Sorry it's not an attachment, the internet group policy in my current location appears to be a bit finicky regarding attachments):
Naturally you’re right about Strings not knowing anything about character encodings. It’s really the encoding of the bytes contained in the String that I’m altering. I’m still not entirely sure I’m being clear though, so where words fail, I’ll just post some code. Here’s my conversion routine:
public static final String stringToAsciiString(String inString)
{
String asciiString = null;
if (inString != null)
{
try
{
byte[] asciiBytes = inString.getBytes("US-ASCII");
asciiString = new String(asciiBytes, "US-ASCII");
}
catch (UnsupportedEncodingException encEx)
{
return null;
// encEx.printStackTrace();
}
}
return asciiString;
}
Hi again Sean,
I just wanted to say thanks again for your assistance on this issue. Turns out that getRawBytes() was just what the doctor ordered. After using that I was able to apply EBCDIC encoding just as you postulated. Success!
Interestingly, it was right around this same time that the external team came through with a separate breakthrough. Ultimately they were able to apply ASCII encoding to the text contained in the barcode. Another success! (And for my money I’ll probably let the external system deal with the extra processing. It’s still great to know that I’m not strictly tied to their encoding though!)
Thanks again, and this issue is most definitely resolved at this point.