Binary data in DataMatrix bar codes
It is possible to store binary data in DataMatrix barcodes, but how do you go about accurately recovering the information?
Take the simple and obvious example of a datamatrix barcode that contains the text “ABCDE”. This can be encoded in multiple ways (e.g C40 or Text Encoding) but the output from the reader will always be “ABCDE”.
In the case of binary data, you don’t need to know what encoding method was used in the datamatrix bar code, but you do need to know how our SDK has encoded the data.
The encoding of data is through the property called Encoding (ST_ENCODING in the Linux SDK).
This can take 1 of 4 values with the default being UTF-8:
0 Raw , with null characters suppressed.
1 Quoted printable
When testing with binary data it is useful to set the encoding to 1 since the string can be easily printed and understood by a human. Non-printable characters are printed as =XX where XX is the hex value of the byte. Printable characters are printed as normal.
Raw format works so long as you don’t have null characters in your binary data.
Note that UTF-8 is not actually an encoding method used in a datamatrix barcode, although the data may happen to already be in UTF-8 format. This can result in double UTF-8 encoding when it is decoded and so we have an additional parameter called DataMatrixAutoUTF8 (ST_DATAMATRIX_AUTO_UTF8 in the Linux SDK) which assesses the data to see if it is already in UTF-8 format before encoding it. If it is already in UTF-8 format and the encoding is set to UTF-8 then it is left alone.