You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently working on a project that uses QR codes. To make sure the generated QR codes are correct, I thought of using your module to decode them and compare the expected content with the decoded content.
Everything was working fine until I tried using Unicode characters. The decoded content no longer match the expected content.
Here is a simple program that showcases this problem:
import pyqrcode
import pyzbar.pyzbar
from PIL import Image
def encodeDecode(content):
# Generate a QR code image from the content
url = pyqrcode.create(content, encoding='utf-8')
url.png('qrcode.png', scale=8)
# Decode the QR code and retrieve the content
decodedContent = pyzbar.pyzbar.decode(Image.open('qrcode.png'))[0].data
# Compare with the original content
if (decodedContent.decode('utf-8') == content):
print("TEST OK with", content)
else:
print("TEST FAILED with", content)
encodeDecode('\u0100') # TEST OK
encodeDecode('\u0101') # TEST OK
encodeDecode('\u2133') # TEST FAIL
encodeDecode('\u0100\u2133') # TEST OK
encodeDecode('\u0101\u2133') # TEST FAIL
And here is the result when executed:
TEST OK with Ā
TEST OK with ā
TEST FAILED with ℳ
TEST OK with Āℳ
TEST FAILED with āℳ
We can see that the character ℳ is not well decoded, but then when appended with Ā, it's working correctly. Even stranger, appended with ā (a character from the same Unicode group), again, the content is incorrectly decoded.
The problem doesn't originate from pyqrcode as all generated QR codes can be decoded correctly using other decoding solution like ZXing for Java, phones, or websites.
The text was updated successfully, but these errors were encountered:
Hi!
I'm currently working on a project that uses QR codes. To make sure the generated QR codes are correct, I thought of using your module to decode them and compare the expected content with the decoded content.
Everything was working fine until I tried using Unicode characters. The decoded content no longer match the expected content.
Here is a simple program that showcases this problem:
And here is the result when executed:
We can see that the character ℳ is not well decoded, but then when appended with Ā, it's working correctly. Even stranger, appended with ā (a character from the same Unicode group), again, the content is incorrectly decoded.
The problem doesn't originate from pyqrcode as all generated QR codes can be decoded correctly using other decoding solution like ZXing for Java, phones, or websites.
The text was updated successfully, but these errors were encountered: