unicode codecs

Peter Otten __peter__ at web.de
Mon Feb 9 17:51:38 EST 2004


Peter Otten wrote:

>>>> def toiso(s):
> ...     if isinstance(s, unicode):
> ...             return u.encode("iso-8859-1")
> ...     return s
> ...
>>>> toiso(u) + toiso(s)
> 'R\xfcbeR\xfcbe'

Oops, that should be:

>>> def toiso(t):
...     if isinstance(t, unicode):
...             return t.encode("iso-8859-1")
...     return t
...
>>> toiso(u) + toiso(s)
'R\xfcbeR\xfcbe'




More information about the Python-list mailing list