Skip to content

Instantly share code, notes, and snippets.

@ngocnhan2003
Last active January 4, 2023 01:43
Show Gist options
  • Select an option

  • Save ngocnhan2003/531e74147438d7566416364ed6ed3758 to your computer and use it in GitHub Desktop.

Select an option

Save ngocnhan2003/531e74147438d7566416364ed6ed3758 to your computer and use it in GitHub Desktop.
Convert dec quoted printable to unicode
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