Python Unicode strangeness.
Martin von Loewis
loewis at informatik.hu-berlin.de
Fri Feb 9 13:07:57 EST 2001
"Syver Enstad" <syver at NOSPAMcyberwatcher.com> writes:
> '%s, %s' % ('æøasfd', u'a')
> this throws unicode error.
>
> Is this by design?
I think so, you should not combine strings with characters > 128 and
Unicode objects: the result should be Unicode, but you can't be
certain in what encoding the string was. To get this to work, do
'%s, %s' % (unicode('æøasfd','latin-1'), u'a')
(if Latin-1 is the encoding that you had intended for that string), or
'%s, %s' % ('æøasfd', u'a'.encode('latin-1'))
Regards,
Martin
More information about the Python-list
mailing list