# HG changeset patch # User Laurent Bessard # Date 1338304297 -7200 # Node ID 314af37f7db27af778d07fd67540e7d3c84f75a7 # Parent 25296cfc366306f94b1259164fc1a76c4c6d6e9e fixing unicode in xmlclass diff -r 25296cfc3663 -r 314af37f7db2 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