Closed maxnoe closed 2 years ago
In [1]: import qrcode In [2]: from io import StringIO In [3]: buffer = StringIO() In [4]: code = qrcode.QRCode() In [5]: code.add_data("Hello") In [6]: code.print_ascii(out=buffer) In [7]: print(buffer.getvalue()) █▀▀▀▀▀█ ▀▀▀█ █▀▀▀▀▀█ █ ███ █ █ █ ▀ █ ███ █ █ ▀▀▀ █ ██ ▄▀ █ ▀▀▀ █ ▀▀▀▀▀▀▀ █ █ ▀ ▀▀▀▀▀▀▀ ▀ ▀█▀▀▀ ▄▀ █▄▄█▀▀██ ▄ █▀▀█▀▄▄▀█▄█▄█▀ ██▀ ▀▀▀ ▀▀█▀▀ █ █ ▄ ▀ █▀▀▀▀▀█ ▄▀▄▀ ▀ ▄█▄██ █ ███ █ █▄ █▄█▄▄▀▄ ▀ █ ▀▀▀ █ ▀█ ▄█▄█▀▄▄█ ▀▀▀▀▀▀▀ ▀▀ ▀ ▀ ▀ In [8]: buffer.getvalue().encode("ascii") --------------------------------------------------------------------------- UnicodeEncodeError Traceback (most recent call last) Input In [8], in <module> ----> 1 buffer.getvalue().encode("ascii") UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-28: ordinal not in range(128)
It uses unicode characters in utf-8 encoding.
Meh, it's using the following character codes from the Extended ASCII code page: 255, 223, 220, 219
Maybe a bit misleading method name, but 🤷🏻
It uses unicode characters in utf-8 encoding.