Created
May 12, 2022 18:22
-
-
Save shinkou/5b0cdf73537080ac993b044eb0689b4f to your computer and use it in GitHub Desktop.
A snippet which does what the unescape function does in Javascript
This file contains 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/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