Skip to content

Instantly share code, notes, and snippets.

@uolot
Created August 20, 2013 22:09
Show Gist options
  • Save uolot/6287991 to your computer and use it in GitHub Desktop.
Save uolot/6287991 to your computer and use it in GitHub Desktop.
Python redirect unicode to stdout with proper encoding
# 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