Last active
January 4, 2023 01:43
-
-
Save ngocnhan2003/531e74147438d7566416364ed6ed3758 to your computer and use it in GitHub Desktop.
Convert dec quoted printable to unicode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import quopri | |
| import re | |
| # cao nh\225\186\165t | |
| # cao nhất | |
| RE_DEC = r'\\\\(\d{3})' | |
| def process(s): | |
| values = re.findall(RE_DEC, s) | |
| for key in list(set(values)): | |
| s = s.replace(f'\\\\{key}', '={0:x}'.format(int(key)).upper()) | |
| res_byte = quopri.decodestring(s) | |
| return res_byte.decode('utf-8') | |
| while True: | |
| print('\nEnter text:') | |
| inp = input() | |
| print(process(repr(inp).strip("'"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment