[Numpy-discussion] Greek Letters

Mark Janikas mjanikas@esri....
Tue Feb 20 19:47:19 CST 2007

Great info.  The last part about the sys.stdout not working everywhere is a bit troubling.  But For now, I am just gonna add a try statement as stated in the previous message.  Thanks again,


PS... The software company I work for has a version that runs on Unix/Linux so I am awaiting a new laptop with which to employ Linux!  I cant wait to get back to my roots.  Debian and Fluxbox.... could there be a better working environment?  

-----Original Message-----
From: numpy-discussion-bounces@scipy.org [mailto:numpy-discussion-bounces@scipy.org] On Behalf Of Robert Kern
Sent: Tuesday, February 20, 2007 5:36 PM
To: Discussion of Numerical Python
Subject: Re: [Numpy-discussion] Greek Letters

Mark Janikas wrote:
> Thanks Robert.... but alas, I get.....
>>>> import sys
>>>> sys.stdout.encoding
> 'cp437'
>>>> print u'\u03a7\u00b2'.encode(sys.stdout.encoding)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "C:\Python24\lib\encodings\cp437.py", line 18, in encode
>     return codecs.charmap_encode(input,errors,encoding_map)
> UnicodeEncodeError: 'charmap' codec can't encode character u'\u03a7' in position
>  0: character maps to <undefined>
> Ill keep at it.... please let me know if you have any solutions....

Yup, CP437 doesn't support the Χ character. You will have to use a terminal that
can accept a full-Unicode encoding like UTF-8 and a font that has the relevant
characters. Most of the modern terminal emulators for Linux et al. are capable
of UTF-8. On Windows, you may be out of luck. I don't know of any
fully-Unicode-capable terminal. Google tells me that cmd.exe takes a /U argument
that should put it in Unicode mode, but that doesn't change anything for me.

I also ran into a case where sys.stdout.encoding is None, so my solution is not
as robust as I thought.

If you use something else for your interpreter shell like IDLE, it is possible
that it supports Unicode. sys.stdout.encoding may not be set appropriately, though.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco
Numpy-discussion mailing list

More information about the Numpy-discussion mailing list