Created
May 10, 2018 04:05
-
-
Save kemadz/ec877f069de5a9f2be74b2cb2b6cc12e to your computer and use it in GitHub Desktop.
fix encoding hell
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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import sys | |
orig = '孃䱋崸㔴㔵' | |
if sys.version_info.major > 2: | |
print(bytes.fromhex(''.join([hex(ord(c)) for c in orig]).replace('0x', '')).decode()) | |
else: | |
print(bytearray.fromhex(''.join([hex(ord(c)) for c in orig.decode('utf-8')]).replace('0x', ''))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment