print u"\u0432": why is this so hard? UnciodeEncodeError

David Eppstein eppstein at ics.uci.edu
Fri Apr 9 03:09:10 EDT 2004


In article <mailman.474.1081470992.20120.python-list at python.org>,
 Hye-Shik Chang <perky at i18n.org> wrote:

> The encoding of darwin terminal can be discovered by the routine
> currently we have.
> 
> perky$ LC_ALL=ko_KR.UTF-8 python
> Python 2.3 (#1, Sep 13 2003, 00:49:11) 
> [GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import sys;sys.stdin.encoding
> 'UTF-8'
> >>> ^D
> perky$ LC_ALL=ko_KR.eucKR python
> Python 2.3 (#1, Sep 13 2003, 00:49:11) 
> [GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import sys;sys.stdin.encoding
> 'eucKR'

Well, no.

Python 2.3 (#1, Sep 13 2003, 00:49:11) 
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys;sys.stdin.encoding
'US-ASCII'

But, in fact, the encoding of my Terminal.App is utf8 (the usual 
default), as set in the Terminal Inspector (Terminal->Window 
Settings...) Display pane, Character Set Encoding menu.

Possibly you can find Terminal's preferred encoding in 
Library/Preferences/com.apple.Terminal.plist (I just looked there, and 
don't see it, unless it's maybe the StringEncoding:4 line) but it can be 
changed from the default on a per-window basis and, like Martin, I don't 
know how to find out its current setting.

-- 
David Eppstein                      http://www.ics.uci.edu/~eppstein/
Univ. of California, Irvine, School of Information & Computer Science



More information about the Python-list mailing list