How to print this character u'\u20ac' to DOS terminal

"Martin v. Lo"wis" martin at v.loewis.de
Wed May 30 01:23:55 EDT 2007


人言落日是天涯,望极天涯不见家 schrieb:
> Who could explain the follow issue ?

>>>> print u'\u0394'
> Δ
>>>> print u'\u20ac'
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> UnicodeEncodeError: 'gbk' codec can't encode character u'\u20ac' in
> position 0:
> illegal multibyte sequence
> 
> My terminal is cmd.exe under windows XP.
> what's the different between the two character ? what can I do if I
> want to print the u'\u20ac'?

The problem is that your terminal uses (some form of) the GBK encoding;
see http://zh.wikipedia.org/wiki/GBK for details on GBK.

It seems that GBK (or, rather, code page 936) supports the delta
character, but not the euro sign.

To change that, you can use "chcp" in your terminal window.
For example, if you do "chcp 850", you should be able to
display the euro sign (but will simultaneously use the ability
to display the letter delta, and the chinese letters).

I don't know whether the terminal supports an UTF-8 code
page; you can try setting the terminal's code page to
65001 (which should be UTF-8).

Regards,
Martin



More information about the Python-list mailing list