

All About Python and Unicode - alexk
http://boodebr.org/main/python/all-about-python-and-unicode

======
newt0311
Excellent article. One of the clearest explanation of how to use unicode in
python that I have seen yet.

~~~
pmorici
Yeah, but it leaves out one important bit that I've never been able to figure
out. How do you use print to output a UTF-8 or some other Unicode encoding w/o
using the repr() call?

~~~
inklesspen
Simply encode your unicode string in utf-8 and print the resulting bytestring.
Simple, huh?

Okay, say you don't want to do u"somestring".encode('utf-8') all the time.
Python has a set of classes that will wrap files and transparently encode and
decode for you. And stdout is just another file.

    
    
      import sys
      import codecs
      sys.stdout = codecs.getwriter("utf-8")(sys.stdout)
      line = u"\u0411"
      print line

