On Sep 4, 4:00 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > In the working case your initial string is a bytestring, in the non-working > case the initial string is unicode. The error comes from trying to replace > into a unicode string a bytestring containing non-ascii chars: > > >>> s = u'asd' > >>> s = s.replace("s", "š") > > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 0: > ordinal not in range(128) > > One fix it to specify the replacement string as a unicode literal instead of > a bytestring: > > >>> s = s.replace("s", u"š") > >>> print s > > ašd
thanks, now i feel like an idiot 8-) Aljosa --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---