[sylvain] r51078 - Formulator/trunk

[email protected] Wed, 11 Sep 2013 17:54:23 +0200 (CEST)
Newsgroups gmane.comp.web.zope.silva.cvs
Message-ID <[email protected]>
Author: sylvain
Date: Wed Sep 11 17:54:22 2013
New Revision: 51078

Modified:
   Formulator/trunk/Widget.py
Log:
Fix more utf-8 issues.


Modified: Formulator/trunk/Widget.py
==============================================================================
--- Formulator/trunk/Widget.py	(original)
+++ Formulator/trunk/Widget.py	Wed Sep 11 17:54:22 2013
@@ -1102,7 +1102,12 @@
 
     if 'contents' in kwargs:
         contents = kwargs.pop('contents')
-        return "%s>%s</%s>" % (render_tag(tag, **kwargs), contents, tag)
+        if not isinstance(contents, unicode):
+            if isinstance(contents, str):
+                contents = contents.decode('utf-8', 'replace')
+            else:
+                contents = unicode(contents)
+        return u"%s>%s</%s>" % (render_tag(tag, **kwargs), contents, tag)
     return render_tag(tag, **kwargs) + " />"
 
 def render_value(value, separator=None):