Displaying Unicode on the console (Windows)

Skip Montanaro skip at pobox.com
Mon Apr 14 18:02:06 CEST 2003


    Paul> To use a concrete example, I'd like to print the Euro symbol. A
    Paul> Unicode string for this is u'\20a0'

    >>>> unicodedata.name(u'\u20a0')
    Paul> 'EURO-CURRENCY SIGN'

    ...
    >>>> print u'\u20a0'.encode("latin-15")
    ...
    >>>> print u'\u20a0'.encode("latin-1")
    ...
    >>>> print u'\u20a0'.encode("iso8859_15")
    ...
    >>>> print u'\u20a0'.encode("cp1258")
    ...
    >>>> print u'\u20a0'.encode("mbcs")
    ...
    Paul> [BTW, in case it's relevant - I know it probably is - the output
    Paul> from "chcp" at the console prompt is "Active code page: 1252"]

Seems that cp1252 is the most likely encoding you didn't try.  What happens
if you execute

    print u'\u20a0'.encode("cp1252")

?

Skip





More information about the Python-list mailing list