Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
40 lines (26 sloc) 898 Bytes
#!/usr/bin/env python3
import sys
def unescape_file(path):
r"""Returns the unicode-unescaped string representing the content of a file
Reads a file containing unicode escape sequences (\uXXXX) returns a
unicode string containing the correct unicode representation of the
Note: this simple implementation will probably not scale to very large
with open(path, 'r') as fd:
s =
return unescape_str(s)
def unescape_str(s):
r"""Returns the unicode-unescaped but otherwise unmodified input string
Re-encodes a string to replace unicode escape sequences (\uXXXX) with
their unicode equivalents
return s.encode('utf-8').decode('unicode-escape')
def main(args):
for arg in args:
s = unescape_file(arg)
with open(arg + '.unescaped', 'w', encoding='utf-8') as outfile:
if __name__ == '__main__':
You can’t perform that action at this time.