Comments (13)
@id1945 Your original qr code can be read correctly by configuring zbar-wasm
to return binary data and delegating text decoding to the native TextDecoder
e.g. like so:
import { ZBarConfigType, ZBarImage, ZBarScanner, ZBarSymbolType } ...;
const scanner = await ZBarScanner.create();
scanner.setConfig(ZBarSymbolType.ZBAR_NONE, ZBarConfigType.ZBAR_CFG_BINARY, 1); // <-- important
scanner.scan(image);
const symbols = scanner.getResults();
However, in order to read the code that I generated correctly, the scanner.config()
statement has to be omitted.
Thus, with a particular setup, either one or the other QR code can be read correctly but not both.
This appears to be one of the peculiarities of the ZBar bar code reader on which zbar-wasm
is based. Unfortunately, there is nothing that I can do about that.
from zbar-wasm.
Thanks @pascalschoeni !
jschardet
did help, although indirectly: it showed me that the raw data of one of my QR code test strings ('ÄÖÜ äöü ß ÁÉÍÓÚ áéíóú ÀÈÌÒÙ àéíóú'
) was not UTF-8 encoded (as it should have been) and therefore was not correctly decoded by the TextDecoder
in UTF-8 mode.
I suspect that the online QR encoder that I used for the test image did not handle the test string properly. Encoding that string again here produced an image which zbar-wasm
decodes correctly.
@id1945 :
The code snippet from my previous comment actually works not only for both variants of your QR code but also for all other barcodes in the unit tests of zbar-wasm
.
Could you please provide me with an image of a QR code that is similar to your original one but does not contain personal data? Before closing this issue, I would like to include such an QR code in the unit tests if possible.
Also, please feel free to delete your original QR code image from this thread.
from zbar-wasm.
Hmm... the raw bytes of the QR code are decoded by the browser's TextDecoder according to the selected character encoding, so there is not much that I can do about false decoding.
On the other hand, are you sure that the QR code is UTF-8 encoded? I googled and found several Vietnamese character encodings.
from zbar-wasm.
I copied your expected text, pasted in into an online QR generator and obtained this QR code:
Scanning this QR code yields the following (correct) result:
This indicates that the text in your QR code is most likely not UTF-8-encoded.
from zbar-wasm.
@undecaf jschardet (https://www.npmjs.com/package/jschardet) may help:
const detectedCharSet = jschardet.detect(Buffer.from(symbol.data))
const text = foundQr.decode(detectedCharSet.encoding)
from zbar-wasm.
@undecaf 🥇 🥇
Luckily for me! 🙏
I found these websites that generate the error QRcode as we are discussed above. Below is the QRcode that I created. You can also create your own in Vietnamese
language.
https://qrplanet.com/#text
https://qrcode.tec-it.com/en/Raw
from zbar-wasm.
The image is confidential, so it should be removed
from zbar-wasm.
Let me explain in more detail: zbar-wasm
delegates decoding the raw bytes contained in the QR code to the text displayed as rawValue
to the TextDecoder
built into each browser. By default, the TextDecoder
uses UTF-8 encoding, but a several other encodings are available.
If the text is not what is expected then I see two possible reasons:
- A bug in the browser's
TextDecoder
-- unlikely but can be verified by trying whether a different browser produces the same text. - The text in the QR code is in an encoding different from UTF-8, so decoding the raw bytes as UTF-8 will likely yield a wrong result.
Therefore I am kindly asking you again whether it can be confirmed that your QR code is actually UTF-8-encoded. The producer of the QR code should be able to provide this information.
from zbar-wasm.
The image is confidential, so it should be removed
from zbar-wasm.
Hmmm... the BarcodeDetector
built into mobile Chrome also reads that code correctly.
Please give me some time to look into that.
from zbar-wasm.
I really hope you get this fixed soon. Since I am developing a library for Angular ngx-scanner-qrcode
based on yours.
And finally, please allow me to delete the photo of my citizenship card in the comment above.
Waiting to hear from you soon ^^!
from zbar-wasm.
@undecaf Thank you very much. I've also tried and it doesn't work at all. It is still a headache for me.
from zbar-wasm.
@undecaf 🥇
I will soon delete all the QR code
containing my personal data here. I will give you another QR code
image with the above error please wait for me. @@
from zbar-wasm.
Related Issues (20)
- webpack error migrating from 0.9.15 -> 0.9.16 HOT 5
- How to bundle zbar.wasm in a module project? HOT 6
- The barcode type DataMatrix is not supported HOT 1
- Please Help : Why i show this error when i tray import the package in Angular 16 HOT 1
- Build fails when using in Next.js App directory router. HOT 2
- [BUG] WebAssembly.Module doesn't parse at byte 1227: invalid opcode 192, in function at index 28 HOT 7
- [BUG] On IOS Safari Iphone 12 - after background/sleep mode reactivation changes camera to fisheye HOT 8
- Feature Suggestion: Allow Passing the Zbar Instance HOT 6
- __dirname is not defined with nextjs HOT 1
- [BUG] Not able to scan the barcode of this image using this library, however able to scan it with the phone app HOT 5
- Prepare for a NPM release of this package please HOT 1
- [BUG] Combined scan symbol type not recognized HOT 1
- [Enhancement] Allow specifying the URL of the WASM file HOT 2
- [BUG] library not being recognized/provided by vite HOT 3
- Paused when failed to detect unsupported code type. HOT 2
- zbar-wasm doesn't work with nodejs 18
- TypeError: Failed to construct 'URL': Invalid URL HOT 5
- after 15 june this package giving an error HOT 2
- loading zbar-wasm as ES module fails in Node HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zbar-wasm.