[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/renderer/stx.py Fixed unicode issue. The STX renderer was not unicode aware.

Stephan Richter srichter at cosmos.phy.tufts.edu
Mon Sep 6 19:27:27 EDT 2004


Log message for revision 27456:
  Fixed unicode issue. The STX renderer was not unicode aware.
  


Changed:
  U   Zope3/trunk/src/zope/app/renderer/stx.py


-=-
Modified: Zope3/trunk/src/zope/app/renderer/stx.py
===================================================================
--- Zope3/trunk/src/zope/app/renderer/stx.py	2004-09-06 23:16:59 UTC (rev 27455)
+++ Zope3/trunk/src/zope/app/renderer/stx.py	2004-09-06 23:27:27 UTC (rev 27456)
@@ -43,19 +43,26 @@
       >>> source = StructuredTextSourceFactory(u'This is source.')
       >>> renderer = StructuredTextToHTMLRenderer(source, TestRequest())
       >>> renderer.render()
-      '<p>This is source.</p>\n'
+      u'<p>This is source.</p>\n'
 
+      Make sure that unicode works as well.
+
+      >>> source = StructuredTextSourceFactory(u'This is \xc3\x9c.')
+      >>> renderer = StructuredTextToHTMLRenderer(source, TestRequest())
+      >>> renderer.render()
+      u'<p>This is \xc3\x9c.</p>\n'
     """ 
     implements(IHTMLRenderer)
     __used_for__ = IStructuredTextSource
 
     def render(self):
         "See zope.app.interfaces.renderer.IHTMLRenderer"
-        doc = Document()(str(self.context))
+        encoded = self.context.encode('UTF-8')
+        doc = Document()(encoded)
         html = HTML()(doc)
 
         # strip html & body added by some zope versions
         html = re.sub(
             r'(?sm)^<html.*<body.*?>\n(.*)</body>\n</html>\n',r'\1', html)
 
-        return html
+        return html.decode('UTF-8')



More information about the Zope3-Checkins mailing list