# HG changeset patch
# User Andrey Skvortsov <andrej.skvortzov@gmail.com>
# Date 1461771750 -10800
# Node ID 5ecb16be9a3c0d88e5edb37e38d282bf59e19a81
# Parent  d3f97b72c02a294e3260cfdbb73b1623cd57de00
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;...'

diff -r d3f97b72c02a -r 5ecb16be9a3c PLCControler.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:
diff -r d3f97b72c02a -r 5ecb16be9a3c xmlclass/xmlclass.py
--- 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):