compare unicode to non-unicode strings
fredrik at pythonware.com
Sun Aug 31 15:42:47 CEST 2008
> how could I test that those 2 strings are the same:
> 'séd' (repr is 's\\xc3\\xa9d')
> u'séd' (repr is u's\\xe9d')
determine what encoding the former string is using (looks like UTF-8),
and convert it to Unicode before doing the comparision.
>>> b = 's\xc3\xa9d'
>>> u = u's\xe9d'
>>> unicode(b, "utf-8")
>>> unicode(b, "utf-8") == u
More information about the Python-list