Displaying Unicode on the console (Windows)
Paul Moore
gustav at morpheus.demon.co.uk
Mon Apr 14 15:54:09 EDT 2003
Irmen de Jong <irmen at -NOSPAM-REMOVE-THIS-xs4all.nl> writes:
> Paul Moore wrote:
[...]
>>>>>unicodedata.name(u'\u20a0')
>> 'EURO-CURRENCY SIGN'
>>
>
> Hmmm
>
>
> >>> import unicodedata
> >>> unicodedata.name(u'\u20ac')
> 'EURO SIGN'
> >>> unicodedata.name(u'\u20a0')
> 'EURO-CURRENCY SIGN'
> >>>
Ah. I got 0x20a0 from an example in a document I read on the web. It
never occurred to me that it might be inaccurate :-(
> I've always used 0x20ac as Euro Sign, €.
> This works nicely in all circumstances, also printing it out on the
> windows console using CP1252 encoding.
>>> print u"\u20ac".encode("cp1252")
€
Brilliant. It looks like my understanding was fine, it was just the
data I was using which was wrong. Wrong Unicode character, and
originally, wrong encoding as well. I knew today was going to be a bad
day :-)
> I didn't know what 0x20a0 is, so I looked it up [1],[2]:
Those are really useful pointers. Thanks a lot. (I know, unicode.org,
obvious place to look. Sorry, I'll do my homework better next time...)
Paul.
PS Is there any way of forcing the Windows 2000/XP console to display
Unicode in any form (UTF-8, maybe) rather than having to deal with
code pages???
--
This signature intentionally left blank
More information about the Python-list
mailing list