On Apr 18, 5:38 pm, [EMAIL PROTECTED] wrote: > I'd like to print out a unicode string. > > I'm running Python inside Emacs, which understands utf-8, so I want to > force Python to send utf-8 to sys.stdout. > > From what I've googled, I think I need to set my locale. I don't > understand how. > > import locale > print locale.getlocale() > --> (None,None) > print locale.getdefaultlocal() > --> ('en_GB','cp1252') > print locale.normalize('en_GB.utf-8') > --> en_GB.UTF8 > locale.setlocale(locale.LC_ALL,'en_GB.UTF8') > --> locale.Error: unsupported locale setting > > I'd be grateful for advice. > Damon.
u_str = u'hell\u00F6 w\u00F6rld' #o's with umlauts print u_str.encode('utf-8') --output:-- hellö wörld -- http://mail.python.org/mailman/listinfo/python-list