Re: compare unicode to non-unicode strings

2008-08-31 Thread Matt Nordhoff
Asterix wrote: > 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') You may also want to look at unicodedata.normalize(). For example, é can be represented multiple ways: >>> import unicodedata >>> unicodedata.normalize('NFC',

Re: compare unicode to non-unicode strings

2008-08-31 Thread MVP
Par Toutatis ! Si tu avais posé la question à Ordralphabétix, ou sur un des ng français consacrés à Python, au lieu de refaire "La grande Traversée", la réponse aurait peut-être été plus rapide. @-salutations -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: compare unicode to non-unicode strings

2008-08-31 Thread Fredrik Lundh
Asterix wrote: 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\xe9

Re: compare unicode to non-unicode strings

2008-08-31 Thread John Machin
On Aug 31, 11:04 pm, Asterix <[EMAIL PROTECTED]> wrote: > 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') [note: your reprs are wrong; change the \\ to \] You need to decode the non-unicode string and compare the result with t

Re: compare unicode to non-unicode strings

2008-08-31 Thread John Machin
On Aug 31, 11:04 pm, Asterix <[EMAIL PROTECTED]> wrote: > how could I test that those 2 strings are the same: > > 'séd' (repr is 's\\xc3\\xa9d') No, the repr is 's\xc3\xa9d'. > > u'séd' (repr is u's\\xe9d') No, the repr is u's\xe9d'. To answer your question: -- http://mail.python.org/mailman

compare unicode to non-unicode strings

2008-08-31 Thread Asterix
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') -- http://mail.python.org/mailman/listinfo/python-list