lincolnloop / python-qrcode

Python QR Code image generator
https://pypi.python.org/pypi/qrcode
Other
4.34k stars 664 forks source link

Disable base64 encoding for strings containing umlauts #249

Open beatjaeckle opened 2 years ago

beatjaeckle commented 2 years ago

Issue

When my string contains umlauts, then it will get encoded as base64. Is it possible to enforce qrcode to not use base64?

Testing

For GNU+Linux systems I wrote a small test to compare it with the qrtools package that comes with qtqr. You need zbar and qtqr from your repo.

#!/bin/env python3
# write images qr_qrcode.png and qr_qrtools.png with the 
import qrcode
from qrtools import QR

s = "Ich bräuchte Umlaute im String"
qc = qrcode.make(s)
qc.save("qr_qrcode.png")

qt = QR(s)
qt.encode("qr_qrtools.png")
#!/bin/bash
zbarimg --xml qr_qrtools.png
echo
zbarimg --xml qr_qrcode.png

Current output

While using qrcode 7.3.1 I get this output from the script:

<barcodes xmlns='http://zbar.sourceforge.net/2008/barcode'>
<source href='qr_qrtools.png'>
<index num='0'>
<symbol type='QR-Code' quality='1' orientation='UP'><data><![CDATA[Ich bräuchte Umlaute im String]]></data></symbol>
</index>
</source>
</barcodes>

<barcodes xmlns='http://zbar.sourceforge.net/2008/barcode'>
<source href='qr_qrcode.png'>
<index num='0'>
<symbol type='QR-Code' quality='1' orientation='UP'><data format='base64' length='32'><![CDATA[
SWNoIGJy//+jdWNodGUgVW1sYXV0ZSBpbSBTdHJpbmc=
]]></data></symbol>
</index>
</source>
</barcodes>

zbar tells me, that the qrtools from qtqr gives me a string, while qrcode uses format=base64.

Goal

My goal is to create a qrcodes containing umlauts with your package without format='base64'.