fixing unicode in xmlclass
authorLaurent Bessard
Tue, 29 May 2012 17:11:37 +0200
changeset 698 314af37f7db2
parent 697 25296cfc3663
child 699 649399ffdaf0
fixing unicode in xmlclass
xmlclass/xmlclass.py
--- a/xmlclass/xmlclass.py	Thu May 24 18:45:16 2012 +0200
+++ b/xmlclass/xmlclass.py	Tue May 29 17:11:37 2012 +0200
@@ -126,13 +126,13 @@
     if not extract:
         return attr
     if len(attr.childNodes) == 1:
-        return unescape(attr.childNodes[0].data.encode("utf-8"))
+        return unicode(unescape(attr.childNodes[0].data))
     else:
         # content is a CDATA
-        text = ""
+        text = u''
         for node in attr.childNodes:
-            if not (node.nodeName == "#text" and node.data.strip() == ""):
-                text += unescape(node.data.encode("utf-8"))
+            if not (node.nodeName == "#text" and node.data.strip() == u''):
+                text += unicode(unescape(node.data))
         return text
 
 
@@ -535,7 +535,7 @@
 def GenerateAnyInfos(infos):
     def ExtractAny(tree):
         if tree.nodeName in ["#text", "#cdata-section"]:
-            return unescape(tree.data.encode("utf-8"))
+            return unicode(unescape(tree.data))
         else:
             return tree