diff --git a/MyQR/mylibs/data.py b/MyQR/mylibs/data.py index e03faba..ea4af12 100644 --- a/MyQR/mylibs/data.py +++ b/MyQR/mylibs/data.py @@ -89,9 +89,10 @@ def alphanumeric_encoding(str): return code def byte_encoding(str): + str = bytes(str, encoding="utf8") code = '' for i in str: - c = bin(ord(i.encode('iso-8859-1')))[2:] + c = bin(i)[2:] c = '0'*(8-len(c)) + c code += c return code @@ -108,11 +109,11 @@ def get_cci(ver, mode, str): else: cci_len = (14, 13, 16, 12)[mindex[mode]] - cci = bin(len(str))[2:] + cci = bin(len(bytes(str, encoding="utf8")))[2:] cci = '0' * (cci_len - len(cci)) + cci return cci if __name__ == '__main__': s = '123456789' v, datacode = encode(1, 'H', s) - print(v, datacode) \ No newline at end of file + print(v, datacode) diff --git a/MyQR/myqr.py b/MyQR/myqr.py index 458bb4e..172a7e7 100644 --- a/MyQR/myqr.py +++ b/MyQR/myqr.py @@ -21,11 +21,8 @@ # See [https://github.com/sylnsfar/qrcode] for more details! def run(words, version=1, level='H', picture=None, colorized=False, contrast=1.0, brightness=1.0, save_name=None, save_dir=os.getcwd()): - supported_chars = r"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ยทยท,.:;+-*/\~!@#$%^&`'=<>[]()?_{}|" - - # check every parameter - if not isinstance(words, str) or any(i not in supported_chars for i in words): + if not isinstance(words, str): raise ValueError('Wrong words! Make sure the characters are supported!') if not isinstance(version, int) or version not in range(1, 41): raise ValueError('Wrong version! Please choose a int-type value from 1 to 40!') @@ -129,4 +126,4 @@ def combine(ver, qr_name, bg_name, colorized, contrast, brightness, save_dir, sa finally: import shutil if os.path.exists(tempdir): - shutil.rmtree(tempdir) \ No newline at end of file + shutil.rmtree(tempdir)