Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Can't detect QR Codes with charset other than UTF-8 #241

Closed
6 of 11 tasks
falu-edo opened this issue Feb 3, 2025 · 4 comments · Fixed by #242
Closed
6 of 11 tasks

bug: Can't detect QR Codes with charset other than UTF-8 #241

falu-edo opened this issue Feb 3, 2025 · 4 comments · Fixed by #242
Assignees
Labels

Comments

@falu-edo
Copy link

falu-edo commented Feb 3, 2025

Plugin(s)

  • Barcode Scanning
  • Face Detection
  • Face Mesh Detection
  • Selfie Segmentation
  • Translation

Version

6.1.0

Platform(s)

  • Android
  • iOS
  • Web

Current behavior

When I want to scan a QR Code which was not encoded with UTF-8 it doesn't detect it. So neither an error nor a success message occurs.

Expected behavior

The QR-Code gets detected in other charsets like ISO-8859-1.

Reproduction

https://nextcloud.benluescher.ch/s/BD8PbboyMcL8YLw

Steps to reproduce

  1. Get the QR Code with charset ISO-8859-1 with the provided link
  2. Start an app like the one capawesome-team/.capacitor-app
  3. Try to scan the qr code

Other information

I found following Code in BarcodeScanner.java:
String rawValue = barcode.getRawValue();
I checked the MLKit page and they state: "It's only available when the barcode is encoded in the UTF-8 format, and for non-UTF8 ones use getRawBytes() instead."
So when I replace the before mentioned code with:
String rawValue = new String(barcode.getRawBytes(), StandardCharsets.UTF_8);
the QR code gets detected.

Capacitor doctor

Latest Dependencies:

@capacitor/cli: 7.0.1
@capacitor/core: 7.0.1
@capacitor/android: 7.0.1
@capacitor/ios: 7.0.1

Installed Dependencies:

@capacitor/cli: 6.2.0
@capacitor/core: 6.2.0
@capacitor/android: 6.2.0
@capacitor/ios: 6.2.0

Before submitting

  • I have read and followed the bug report guidelines.
  • I have attached links to possibly related issues and discussions.
  • I understand that incomplete issues (e.g. without reproduction) are closed.
@robingenz
Copy link
Member

Thanks, I will fix this.

@robingenz
Copy link
Member

@falu-edo Please give this dev version a try and let me know if it works now:

npm i https://pkg.pr.new/capawesome-team/capacitor-mlkit/@capacitor-mlkit/barcode-scanning@a8f59b9

@falu-edo
Copy link
Author

falu-edo commented Feb 4, 2025

Hi @robingenz thank you very much! It works now. Do you have any idea when this fix is rolled out in a new version of this library?

@robingenz
Copy link
Member

I plan to publish a new release by the end of the week. However, you can just use the pre-release for now.

robingenz added a commit that referenced this issue Feb 4, 2025
* feat(barcode-scanning): return the raw bytes of a barcodes

Close #241

* fix: handle `null` values

* docs [skip ci]

* wip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants