Skip to content

Instantly share code, notes, and snippets.

@eduardomazolini
Last active June 15, 2021 21:41
Show Gist options
  • Save eduardomazolini/2466eda91ff8cff379ad83031c334e58 to your computer and use it in GitHub Desktop.
Save eduardomazolini/2466eda91ff8cff379ad83031c334e58 to your computer and use it in GitHub Desktop.
PyQRCode adicionei 2 funções usando UNICODE. Não funcionou corretamente no terminal do windows com WSL
###
#ref UNICODE chars
#https://en.wikipedia.org/wiki/Box-drawing_character
import pyqrcode
def qr_doble(txt):
print(txt.replace('0','\U00002588\U00002588').replace('1',' '))
def half_char(u, d):
half_matrix = {
('0', '0'):'\U00002588',
('1', '1'):' ',
('1', '0'):'\U00002584',
('0', '1'):'\U00002580'
}
return half_matrix[(u,d)]
def qr_half(txt):
a = txt.split('\n')
i = 0
r = ''
while i < len(a):
l1 = a[i]
i += 1
l2 = a[i]
if (l2 < l1):
l2 += '1'*len(l1)
i += 1
r += ''.join(map(half_char,list(l1),list(l2)))+'\n'
print(r)
if __name__ == "__main__":
url = pyqrcode.create('http://uca.edu')
print(url.terminal())
qr_doble(url.text())
qr_half(url.text())
@eduardomazolini
Copy link
Author

eduardomazolini commented Jan 10, 2021

image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment