jsQR icon indicating copy to clipboard operation
jsQR copied to clipboard

Code with Chinese can't be parsed

Open VincentTV opened this issue 4 years ago • 3 comments

These two QR codes are generated using the same way, and the one on the left that contains Chinese cannot be parsed.

qrcode

Return Data: Res

VincentTV avatar Sep 23 '21 05:09 VincentTV

Another example. https://upload.wikimedia.org/wikipedia/commons/3/32/Japan-qr-code-billboard.jpg in https://en.wikipedia.org/wiki/QR_code Japan-qr-code-billboard

The content of this QR code is "http://sagasou.mobi

MEBKM:TITLE:探そうモビで専門学校探し!;URL:http://sagasou.mobi;;". jsQR returns code, but code.data is an empty string.

dlwe avatar Dec 27 '21 09:12 dlwe

Due to how "data" is handled in this lib, you may not use it if the code doesn't contain ASCII data (which it does not, here). You also happen to use an old text encoding (notably GBK) and in JS this is not exactly trivial to handle traditionally. You may instead use "binaryData" and a TextDecoder in this way:

new TextDecoder("gbk").decode(Uint8Array.from(result.binaryData))

And that'll give you the string you were trying to get.

Arno500 avatar Aug 17 '22 16:08 Arno500

You must use correct encoding to parse raw result.

fengdh avatar Aug 24 '22 04:08 fengdh