From 18cf9e31729bc67d1567c31d21ba4061438f670c Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Wed, 15 Mar 2017 11:45:42 +0100 Subject: [PATCH] CURA-3500 Make sure that material XMLs have utf-8 encoding --- plugins/XmlMaterialProfile/XmlMaterialProfile.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/XmlMaterialProfile/XmlMaterialProfile.py b/plugins/XmlMaterialProfile/XmlMaterialProfile.py index ccc0dad08e..7dc565ce26 100644 --- a/plugins/XmlMaterialProfile/XmlMaterialProfile.py +++ b/plugins/XmlMaterialProfile/XmlMaterialProfile.py @@ -248,11 +248,12 @@ class XmlMaterialProfile(InstanceContainer): root = builder.close() _indent(root) - stream = io.StringIO() + stream = io.BytesIO() tree = ET.ElementTree(root) - tree.write(stream, encoding="unicode", xml_declaration=True) + # this makes sure that the XML header states encoding="utf-8" + tree.write(stream, encoding="utf-8", xml_declaration=True) - return stream.getvalue() + return stream.getvalue().decode('utf-8') # Recursively resolve loading inherited files def _resolveInheritance(self, file_name):