QR码-原始二进制数据 [英] QR Codes - raw binary data

查看:249
本文介绍了QR码-原始二进制数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道是否有办法使用android vision API获取QR码的原始二进制数据吗?
我正在读取的QR码中包含二进制数据(包括NUL字符),但是使用8位编码构建,因此存在完整的二进制数据块。
返回的Barcode对象非常有帮助,在rawValue字段中包含字符串 Unknown encoding,而不是我的二进制数据?
感谢您的任何想法!

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!

推荐答案

要回答我自己的问题,似乎android vision和zxing库都可以转换如果未在QR代码中指定编码(或默认保留),则为utf8的字节。我以为默认编码为ISO8859-1,但是库并不以此为假设。
QR代码是在Linux中使用libqrencode生成的。在生成时将QR码中的ECI标头设置为1会导致android库保留二进制数据。
因此,使用 barcodes.valueAt(0).displayValue.getBytes( iso-8859-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.

这篇关于QR码-原始二进制数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆