Re: UnicodeDecodeError when using replace on model field

2008-09-04 Thread Aljosa Mohorovic
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'as

Re: UnicodeDecodeError when using replace on model field

2008-09-04 Thread Karen Tracey
2008/9/4 Aljosa Mohorovic <[EMAIL PROTECTED]> > > i can't figure out what's the problem (i also used re with same > results). how should i replace a pattern with non-ascii char? > > working as expected: > In [27]: s > Out[27]: 'asd' > In [28]: s = s.replace("s", "š") > In [29]: s > Out[29]: 'a\xc5

UnicodeDecodeError when using replace on model field

2008-09-04 Thread Aljosa Mohorovic
i can't figure out what's the problem (i also used re with same results). how should i replace a pattern with non-ascii char? working as expected: In [27]: s Out[27]: 'asd' In [28]: s = s.replace("s", "š") In [29]: s Out[29]: 'a\xc5\xa1d' not working on model fields: In [30]: p = Page.objects.al