QR Codes - raw binary data
Asked Answered
R

1

1

Does anybody know if there is a way to get the raw binary data of a QR code using the android vision API ? The QR codes I am reading have binary data (including NUL characters) in them but are built with 8 bit encoding so the full binary data block is there. The Barcode object returned very helpfully has the string "Unknown encoding" in the rawValue field, instead of my binary data ? Thanks for any ideas!

Randall answered 15/7, 2016 at 14:37 Comment(2)
Did you manage to solve this without changing your QR codes? I am facing the very same problem, but I cannot change codes as you did...Lanceolate
No, luckily for me I could modify the software that generated the codes too. That made it work as I expected.Randall
R
2

To answer my own question, it seems both the android vision and zxing libraries convert the bytes to utf8 if the encoding is not specified in the QR code (or left at default). I thought that the default encoding was ISO8859-1 but the libraries don't assume that. The QR code was generated using libqrencode in linux. Setting the ECI header to 1 in the QR code when generated causes the android libraries to preserve the binary data. So, reading the byte array with barcodes.valueAt(0).displayValue.getBytes("iso-8859-1"); returns the exact encoded bytes.

Randall answered 21/7, 2016 at 14:18 Comment(1)
I'm using the same QR code generator as you, libqrencode, and I have the same problem but i don't understand. Where do you change the ECI header to 1 ?Morion

© 2022 - 2024 — McMap. All rights reserved.