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

Discussion in 'Python' started by damonwischik, Mar 27, 2008.

  1. damonwischik

    damonwischik Guest

    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

    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.

    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?

    damonwischik, Mar 27, 2008
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.