Created
August 20, 2013 22:09
-
-
Save uolot/6287991 to your computer and use it in GitHub Desktop.
Python redirect unicode to stdout with proper encoding
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
# src: http://stackoverflow.com/a/4546129 | |
import codecs | |
import locale | |
import sys | |
# Wrap sys.stdout into a StreamWriter to allow writing unicode. | |
sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout) | |
uni = u"\u001A\u0BC3\u1451\U0001D10C" | |
print uni |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment