Last active
August 29, 2015 13:57
-
-
Save polymorphm/9891626 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
assert str is not bytes | |
def js_unicode_escape(unicode_str): | |
assert isinstance(unicode_str, str) | |
return ''.join(('\\u{:04x}'.format(ord(char)) for char in unicode_str)) | |
print(js_unicode_escape('фигня')) |
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/bash | |
python3 -c'import sys; print("".join(("\\u{:04x}".format(ord(char)) for char in sys.argv[1])))' 'фигня' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment