[Zope3-dev] Re: unicode problems !?

Bjorn Tillenius bjoti777 at student.liu.se
Mon Oct 11 07:11:16 EDT 2004


On Fri, Oct 08, 2004 at 01:35:13PM +0200, j.kartnaller wrote:
> Stephan Richter wrote:
> >On Friday 08 October 2004 03:01, j.kartnaller wrote:
> >
> >>1.
> >>If a doc-string contains non ascii data (eg. german umlaut) I get the
> >>following error :
> >>
> >>UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 4:
> >>ordinal
> >>not in range(128)
> >
> >
> >If you have umlauts in the doc string, you must make it a unicode text. 
> >Example:
> >
> >def func():
> >    u"""This is the docstring with an umlaut: ü"""
> >
> >The doc tool has no way of guessing the encoding you may have used.
> >
> I tried this without a change in the behavior !

I noticed that reST renderer outputs a utf-8 encoded string, not
unicode. If the attached patch is applied, it should work better. Any
with more knowledge about the renderer maybe knows if it would cause any
problems applying it?

Of course, you still have to specify the encoding you use with: 

# -*- coding: latin-1 -*-

or whatever encoding you use.

Regards,

Bjorn
-------------- next part --------------
Index: src/zope/app/renderer/rest.py
===================================================================
--- src/zope/app/renderer/rest.py	(revision 27793)
+++ src/zope/app/renderer/rest.py	(working copy)
@@ -149,6 +149,8 @@
             'report_level': 1,
             'halt_level': 6,
             'stylesheet': 'zope3.css',
+            'input_encoding': 'unicode',
+            'output_encoding': 'unicode'
             }
         html = docutils.core.publish_string(
             self.context,


More information about the Zope3-dev mailing list