Skip to content

Instantly share code, notes, and snippets.

@shinkou
Created May 12, 2022 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shinkou/5b0cdf73537080ac993b044eb0689b4f to your computer and use it in GitHub Desktop.
Save shinkou/5b0cdf73537080ac993b044eb0689b4f to your computer and use it in GitHub Desktop.
A snippet which does what the unescape function does in Javascript
#!/usr/bin/env python3
# vim: fileencoding=utf-8 ff=unix lcs=tab\:>. list noet sw=4 ts=4 tw=0
#
# How to use:
# $ unescape.py 'Line 1\nLine 2\nLine 3\n' 'いち\nに\nさん\n'
#
import sys
def unescape(s):
return s.encode('raw_unicode_escape').decode('unicode_escape')
def main():
for arg in sys.argv[1::]:
print(unescape(arg))
if '__main__' == __name__:
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment