[Zope] unicodedecoderror in page templates

Peter Bengtsson peter at fry-it.com
Sun May 20 08:36:53 EDT 2007


It's because somewhere you have a string that is part of the page
template that looks like this:
'st\xc3\xb8rste' (when it should be u'st\xc3\xb8rste') and this is
"merged" with a proper unicode string.

Check this out:
>>> x="st\303\270rste"
>>> print x
største
>>> x + u'S'
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
2: ordinal not in range(128)

Try to make sure all strings that contain non-ascii charaters are
encoded properly as unicode and you'll be fine. Remember to be
consistent with the encoding.

On 5/20/07, Einar Næss Jensen <einar.nass.jensen at gmail.com> wrote:
> When I get errors like:
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2940:
> ordinal not in range(128)
> how can I locate the character which causes the error?
> In particular: where is the position (2940 in the example)?
>
> Best Regards
> EInar Næss Jensen
>
> --
> --
> Einar Næss Jensen
> http://einarblog.homemade.no/einarblog
>  http://www.homemade.no
> tlf: +47 90990249
> (\__/)
> (='.'=)This is Bunny. Copy and paste bunny into your
> (")_(")signature to help him gain world domination.
> _______________________________________________
> Zope maillist  -  Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
>
>


-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com


More information about the Zope mailing list