Reading Pure Byte Data from a QR Code

3,229 views
Skip to first unread message

Brandon DeHart

unread,
Jun 27, 2008, 5:36:16 PM6/27/08
to zxing
Hi,

Just wondering about how the QR decoder is actually processing the
data when the QR code is in Byte mode. It appears to check an encoding
and apply it to the data based on a reasonable guess and create a
string from it, however if it is in byte mode would it not be more
user friendly to simply output the bytes that are found and allow them
to modify it as they will?

I've run into an issue where the data that is in my QR code is encoded
using raw bytes, but when decoded any byte which has a high bit set
(byte >= 0x80) is just reset to the question mark symbol (0x63) since
it has assumed UTF-8.

Let me know if there is already a method somewhere that I haven't been
able to find where I can pull the data from without having the
encoding guessed.

Thanks for any help,

Brandon

srowen

unread,
Jun 27, 2008, 6:16:32 PM6/27/08
to zxing
Yeah you can always call Result.getRawBytes() to get the raw bytes of
the barcode, where applicable -- such as with QR Codes.

My reading of the spec is that QR Codes (and Data Matrix) are trying
to encode strings, not bytes. "Byte mode" is a bit of a bad name since
both the QR Code 2005 spec and previous specs suggest the bytes should
be interpreted according to (differing!) character encodings. It also
suggests using ECI designators to specify character encoding.

But yes you're always welcome to look at the raw bytes.

wilddom

unread,
Jul 8, 2008, 5:50:32 AM7/8/08
to zxing
Well, the raw bytes are not really helpful because they contain the
raw bitstream with all the QR code headers and not the real payload.
Hence parsing the bitstream would cause something like a
reimplementation of the DecodedBitStreamParser. I do agree in your
interpretation of the specs, it wasn't planed to encode binary data.

Defining a 8-bit character set in the ECI designator was the easiest
solution for me. In that case I've had to decode the String afterwards
in my ResultParser with the same character set back to a byte array.
We've successfully encoded ordinary Midi-Files in QR Codes and finally
played them back on cell phones (with a rewritten javame client of
course).

srowen

unread,
Jul 8, 2008, 10:00:24 AM7/8/08
to zxing
Sounds good. Yes I think getting bytes back out of a String, by using
some encoding like ISO-8859-1, sounds like a perfectly reasonable
solution. I wrote in support for ECI character encoding designators
just recently. You could also copy DecodedBitStreamParser and cut it
down, perhaps customize it a bit, to get at your data from the raw
bytes.
Reply all
Reply to author
Forward
0 new messages