fix copying elements with non-latin content like comment element, or
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Wed, 27 Apr 2016 18:42:30 +0300
changeset 1505 5ecb16be9a3c
parent 1504 d3f97b72c02a
child 1506 b9b8978dbc9d
fix copying elements with non-latin content like comment element, or
variables with description in non-latin character set

before any non-latin text was converted after copying to strings like '&#1069;&#1090;&#1086;...'
PLCControler.py
xmlclass/xmlclass.py
--- a/PLCControler.py	Mon Apr 25 17:23:04 2016 +0300
+++ b/PLCControler.py	Wed Apr 27 18:42:30 2016 +0300
@@ -2317,7 +2317,7 @@
             new_id = {}
 
             try:
-                instances, error = LoadPouInstances(text.encode("utf-8"), bodytype)
+                instances, error = LoadPouInstances(text, bodytype)
             except:
                 instances, error = [], ""
             if error is not None or len(instances) == 0:
--- a/xmlclass/xmlclass.py	Mon Apr 25 17:23:04 2016 +0300
+++ b/xmlclass/xmlclass.py	Wed Apr 27 18:42:30 2016 +0300
@@ -1690,7 +1690,7 @@
         return etree.QName(self.tag).localname
         
     def tostring(self):
-        return NAMESPACE_PATTERN.sub("", etree.tostring(self, pretty_print=True))
+        return NAMESPACE_PATTERN.sub("", etree.tostring(self, pretty_print=True, encoding='utf-8')).decode('utf-8')
 
 class XMLElementClassLookUp(etree.PythonElementClassLookup):