QR Codes - raw binary data

▼魔方 西西 提交于 2019-12-08 04:41:34

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/38398840/qr-codes-raw-binary-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!