mchehab / zbar

ZBar is an open source software suite for reading bar codes from various sources, including webcams. As its development stopped in 2012, I took the task of keeping it updated with the V4L2 API. This is the main repository for it. There's a clone at at LinuxTV.org, and another one at gitlab.
https://linuxtv.org/downloads/zbar/
GNU Lesser General Public License v2.1
1k stars 206 forks source link

encoding mode of zbarimg #244

Open RexWzh opened 1 year ago

RexWzh commented 1 year ago

The executable zbarimg doesn't seem to support UTF8 mode. For example, the text "你好" is decoded to be "你好".

nihao

Also, the --xml option has the possibility of encoding garbled characters, when dealing with Kanji mode or special characters in the Byte mode. For example, the text ]]> is decoded to be \nXV0+\n.

test

Flexible support for encoding rules can be cumbersome. Is there any function (or API) that can return a list of QR code matrices directly? This would provide more flexible operations. Thanks in advance!!

JamesR98 commented 1 month ago

A hint is given here:

E4 BD A0 E5 A5 BD is the correct UTF-8 encoded form of "你好". C3 A4 C2 BD C2 A0 C3 A5 C2 A5 C2 BD is what happens when the UTF-8 codeunits are upscaled as-is into UTF-16 codeunits (ie E4 -> E400, BD -> BD00, etc) and then encoded into UTF-8.

https://stackoverflow.com/questions/77593336/c-inputting-outputting-utf-8-on-windows#comment136808755_77593336

A (fragile) workaround:

qrencode 'hello is 你好' -o - | zbarimg --raw -q - | iconv -f utf8 -t utf16le | tr -d '\0'