[Zope3-dev] Publisher bug

Velko Ivanov dachev at nove.bg
Mon Sep 19 06:56:50 EDT 2005


Roger Ineichen wrote:

> Exception Type
> UnicodeDecodeError
> Exception Value
> 'ascii' codec can't decode byte 0xc3 in position 891: ordinal not in
> range(128)
> ...
> body = ('%s\n<base href="%s" />\n%s' % 
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 891:
> ordinal not in range(128) 

I got plenty of these recently, but it was all my fault. I was trying to 
output some unicode strings with non-english characters and it took me 
some time until I got it right.
If you have strings in .py files, which contain non-english characters, 
try the following:

- save your .py files as utf8
- put a comment on the first, or second line of the file:
   # coding: utf8
   this takes care of python's warning
- decode all offending strings:
   'some string'.decode('utf8')




Regards,
Velko Ivanov


More information about the Zope3-dev mailing list