在二维码中存储二进制数据 [英] Storing binary data in QR codes

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

问题描述

我正在尝试将二进制数据存储在二维码中.显然二维码确实支持存储原始二进制数据(或 ISO-8859-1/Latin1).这是我要编码的内容(十六进制):

d1 50 01 00 00 00 f6 5f 05 2d 8f 0b 40 e2 01

我尝试了以下编码器:

  1. 进行解码会产生各种不正确的结果.两个 javascript 产生了这个(这是错误的;第一个文本字符应该是 Ñ.

    而 Google Charts 产生这个...

    这是怎么回事?这些是正确的吗?真正奇怪的是,如果我对这个序列进行编码(至少使用 JS 序列),那么它就可以正常工作 - 我本以为问题是非 ASCII 字符,但 Ñ (0xd1) 是非 ASCII.

    d1 50 01 00 00 00 01 02 03 04 05 06 40 e2 01

    有人知道这是怎么回事吗?

    更新

    我突然想到尝试使用我找到的基于 ZBar 的扫描仪应用程序扫描它们.它可以扫描两个 JS 版本(至少它们以 ÑP 开头).谷歌图表是错误的.所以问题似乎出在 ZXing 上(这太糟糕了 - 我不会向任何人推荐它).

    更新 2

    ZBar 不能处理空字节.:-(

    解决方案

    结果证明 ZXing 只是垃圾,而 ZBar 对数据做了一些奇怪的事情(例如将其转换为 UTF-8).我设法让它输出包括空字节在内的原始数据.这是我发现的最佳 Android ZBar 库的补丁,现已合并.

    I'm trying to store binary data in a QR code. Apparently QR codes do support storing raw binary data (or ISO-8859-1 / Latin1). Here is what I want to encode (hex):

    d1 50 01 00 00 00 f6 5f 05 2d 8f 0b 40 e2 01
    

    I've tried the following encoders:

    1. qr.js

    1. Google Charts

    1. qrcode.js

    Decoding with zxing.org produces various incorrect results. The two javascript ones produce this (it's wrong; the first text character should be Ñ.

    Whereas Google Charts produces this...

    What is going on? Are any of these correct? What's really weird is that if I encode this sequence (with the JS ones at least) then it works fine - I would have thought the issue was non-ASCII characters but Ñ (0xd1) is non-ASCII.

    d1 50 01 00 00 00 01 02 03 04 05 06 40 e2 01
    

    Does anyone know what is going on?

    Update

    It occurred to me to try scanning them with a ZBar-based scanner app I found. It scans both JS versions ok (at least they start with ÑP). The Google Charts one is just wrong. So it seems like the issue is with ZXing (which is surprisingly shit - I wouldn't recommend it to anyone).

    Update 2

    ZBar can't handle null bytes. :-(

    解决方案

    It turned out that ZXing is just crap, and ZBar does some weird stuff with the data (converting it to UTF-8 for example). I managed to get it to output the raw data including null bytes though. Here is a patch for the best Android ZBar library I found, that has now been merged.

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

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