Displaying Unicode on the console (Windows)
Irmen de Jong
irmen at -NOSPAM-REMOVE-THIS-xs4all.nl
Mon Apr 14 14:09:30 EDT 2003
Paul Moore wrote:
> OK. I know this is a common question, and I know the answer is
> basically "it's not as easy as you think" :-) But I'm confused as to
> what I need to do to get a Unicode string to print on the console in
> Windows.
>
> To use a concrete example, I'd like to print the Euro symbol. A
> Unicode string for this is u'\20a0'
>
>
>>>>unicodedata.name(u'\u20a0')
>
> 'EURO-CURRENCY SIGN'
>
Hmmm
>>> import unicodedata
>>> unicodedata.name(u'\u20ac')
'EURO SIGN'
>>> unicodedata.name(u'\u20a0')
'EURO-CURRENCY SIGN'
>>>
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.
I didn't know what 0x20a0 is, so I looked it up [1],[2]:
"The new single currency for member countries of the European Monetary Union
(EMU) is the euro. The euro character is encoded in the Unicode Standard as
U+20AC EURO SIGN.
To avoid confusion, the historical character U+20A0 EURO-CURRENCY SIGN has
been updated with an informative note and a cross reference to U+20AC EURO
SIGN."
It appears to me that 0x20a0 was intented for the Euro sign at the time
the Euro was not yet a "real" currency, but only a "ECU".
--
[1] http://www.unicode.org/reports/tr8/#Euro%20Sign
(although this document has been superseded by a new Unicode standard,
it pretty much explains what was going on).
[2] http://www.unicode.org/charts/PDF/U20A0.pdf
(A nice chart that clearly shows that 0x20a0 is *not* the Euro sign).
More information about the Python-list
mailing list