Set sys.stdout.encoding to utf8 in emacs/python-mode?

damonwischik at gmail.com damonwischik at gmail.com
Thu Mar 27 13:34:19 EDT 2008


I use emacs 22 and python-mode. Emacs can display utf8 characters
(e.g. when I open a utf8-encoded file with Chinese, those characters
show up fine), and I'd like to see utf8-encoded output from my python
session.

>From googling, I've found references to
* locale.getdefaultlocale(), which is ('en_GB', 'cp1252')
* sys.stdout.encoding, which is None
* the environment variables LANG, LC_CHARSET and LC_ALL.
http://mail.python.org/pipermail/python-list/2006-January/360068.html

Should setting those environment variables give me a
sys.stdout.encoding of utf8? What should I set them to? I tried
setting LANG to en_GB and LC_CHARSET to utf8, but it doesn't have the
effect of changing getdefaultlocale() or sys.stdout.encoding.

Or is there some option I can set for python-mode so that it will
instruct the python interpreter to use utf8 for its output?

Damon.




More information about the Python-list mailing list