unicodedecoderror in page templates
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.
--On 20. Mai 2007 14:20:38 +0200 Einar Næss Jensen <einar.nass.jensen@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)?
First you must provide the *full* traceback. -aj
On 5/20/07, Andreas Jung <lists@zopyx.com> wrote:
--On 20. Mai 2007 14:20:38 +0200 Einar Næss Jensen <einar.nass.jensen@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)?
First you must provide the *full* traceback.
sorry....: Request URL http://localhost:10080/ordredfolder/einar.jensen/testview Exception Type UnicodeDecodeError Exception Value 'ascii' codec can't decode byte 0xc3 in position 2940: ordinal not in range(128) Traceback (innermost last): Module ZPublisher.Publish, line 114, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 40, in call_object Module Shared.DC.Scripts.Bindings, line 311, in __call__ Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec Module Products.PageTemplates.PageTemplateFile, line 110, in _exec Module Products.PageTemplates.PageTemplate, line 105, in pt_render <PageTemplateFile at /ordredfolder/einar.jensen/testview> Module StringIO, line 271, in getvalueUnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2940: ordinal not in range(128) -- -- 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.
--On 20. Mai 2007 14:50:12 +0200 Einar Næss Jensen <einar.nass.jensen@gmail.com> wrote:
On 5/20/07, Andreas Jung <lists@zopyx.com> wrote:
--On 20. Mai 2007 14:20:38 +0200 Einar Næss Jensen <einar.nass.jensen@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)?
First you must provide the *full* traceback.
sorry....:
Request URL http://localhost:10080/ordredfolder/einar.jensen/testview Exception Type UnicodeDecodeError Exception Value 'ascii' codec can't decode byte 0xc3 in position 2940: ordinal not in range(128)
Traceback (innermost last): Module ZPublisher.Publish, line 114, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 40, in call_object Module Shared.DC.Scripts.Bindings, line 311, in __call__ Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec Module Products.PageTemplates.PageTemplateFile, line 110, in _exec Module Products.PageTemplates.PageTemplate, line 105, in pt_render <PageTemplateFile at /ordredfolder/einar.jensen/testview> Module StringIO, line 271, in getvalueUnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2940: ordinal not in range(128)
As Peter wrote: you are likely mixing somewhere different encodings with unicode or something similar. Which Zope version are you using? If 2.10 then you might check at the UnicodeConflictResolver as introduced in Zope 2.10 (check the release notes). Otherwise ensure that you are not mixing unicode strings with non-unicode strings. -aj
According to Andreas Jung:
[...]
--On 20. Mai 2007 14:20:38 +0200 Einar Næss Jensen <einar.nass.jensen@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)?
[...]
As Peter wrote: you are likely mixing somewhere different encodings with unicode or something similar. Which Zope version are you using? If 2.10 then you might check at the UnicodeConflictResolver as introduced in Zope 2.10 (check the release notes). Otherwise ensure that you are not mixing unicode strings with non-unicode strings.
With Zope < 2.10 you can try the following recipe to get right (ie wrong) part of the template: http://zwiki.org/UnicodeDecodeErrors \wlang{} -- Willi.Langenberger@wu-wien.ac.at Fax: +43/1/31336/9207 Zentrum fuer Informatikdienste, Wirtschaftsuniversitaet Wien, Austria
On 5/20/07, Willi Langenberger <wlang@wu-wien.ac.at> wrote:
According to Andreas Jung:
[...]
--On 20. Mai 2007 14:20:38 +0200 Einar Næss Jensen <einar.nass.jensen@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)?
[...]
As Peter wrote: you are likely mixing somewhere different encodings with unicode or something similar. Which Zope version are you using? If 2.10 then you might check at the UnicodeConflictResolver as introduced in Zope 2.10 (check the release notes). Otherwise ensure that you are not mixing unicode strings with non-unicode strings.
With Zope < 2.10 you can try the following recipe to get right (ie wrong) part of the template:
Thank you! I'm on zope 2.8.9.1 That's just what I was looking for... -- 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.
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@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@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
participants (4)
-
Andreas Jung -
Einar Næss Jensen -
Peter Bengtsson -
Willi Langenberger