How does unicode() work?
Fredrik Lundh
fredrik at pythonware.com
Wed Jan 9 07:44:48 EST 2008
Robert Latest wrote:
> Here's a test snippet...
>
> import sys
> for k in sys.stdin:
> print '%s -> %s' % (k, k.decode('iso-8859-1'))
>
> ...but it barfs when actually fed with iso8859-1 characters. How is this
> done right?
it's '%s -> %s' % (byte string, unicode string) that barfs. try doing
import sys
for k in sys.stdin:
print '%s -> %s' % (repr(k), k.decode('iso-8859-1'))
instead, to see what's going on.
</F>
More information about the Python-list
mailing list