Last active
January 4, 2016 01:59
-
-
Save jadient/8551803 to your computer and use it in GitHub Desktop.
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 re | |
def replace_one_hex_with_chr(m): | |
return str(unichr(int(m.group()[1:], 16))) | |
def replace_hex_with_chr(s): | |
return re.sub(r'%[0-9A-Fa-f][0-9A-Fa-f]', replace_one_hex_with_chr, s) | |
if __name__ == '__main__': | |
import sys, os | |
if len(sys.argv) < 2: | |
print 'Usage: %s <string>' % os.path.basename(sys.argv[0]) | |
print 'where <string> contains %xx hex escapes' | |
else: | |
print replace_hex_with_chr(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment