Windows XP unicode and escape sequences

John Roth JohnRoth1 at jhrothjr.com
Fri Dec 14 01:27:59 EST 2007


On Dec 12, 2:51 pm, <jyoun... at kc.rr.com> wrote:
> I mainly work on OS X, but thought I'd experiment with some Python code on XP.  The
> problem is I can't seem to get these things to work at all.
>
> First of all, I'd like to use Greek letters in the command prompt window, so I was going to
> use unicode to do this.  But in the command prompt, the unicode characters are displaying
> as strange looking characters.  I tried installing the 'Bitstream Vera Sans Mono' font in hopes
> it had all the characters I needed but this didn't seem to work either.  Is the problem the font?
> And if so, is there a certain font that has unicode '03B1', etc?  Here's some code I tried:
>
> v = u'\u03B1\u03B2\u03B3'.encode('utf-8')
> print v #just displays squares

You've got two problems. First, you don't need to encode it; if the
command prompt window displayed your output after encoding it would
display the multi-byte form of your characters. You should just send
it a unicode object.

Second, check the .encoding attribute of the sys.stdout object.
Therein lies enlightenment about what the command prompt window will
accept.

No info on your other problem.

John Roth

>
> If anyone has any thoughts, I'd love to hear them.
>
> Thanks!
>
> Jay




More information about the Python-list mailing list