Open VincentTV opened 3 years ago
Another example. https://upload.wikimedia.org/wikipedia/commons/3/32/Japan-qr-code-billboard.jpg in https://en.wikipedia.org/wiki/QR_code
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.
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.
You must use correct encoding to parse raw result.
These two QR codes are generated using the same way, and the one on the left that contains Chinese cannot be parsed.
Return Data: