How to display unicode with the CGI module?

coldpizza vriolk at gmail.com
Sun Nov 25 22:02:26 CET 2007


> Unicode != UTF-8.
...
>`encode()` method is your friend.

Thanks a lot for help!

I am always confused as to which one to use: encode() or decode(); I
have initially tried decode() and it did not work.

It is funny that encode() and decode() omit the name of the other
encoding (Unicode ucs2?), which makes it far less readable than a
s.recode('ucs2','utf8').

Another wierd thing is that by default Python converts internal
Unicode to ascii. Will it be the same in Py3k? string*.
> Just to expand on this... It helps thinking of "unicode objects" and
> "strings" as seperate types (which they are). So there is no such thing
> like "unicode string" and you always need to think about when to
> encode() your unicode objects. However, this will change in py3k...,
> what's the new rule of thumb?
>
> cheers
>   Paul



More information about the Python-list mailing list