Explicitly treat all files as UTF-8.

This commit is contained in:
Stefan Rado
2014-02-16 01:51:37 +01:00
parent 1c13225b19
commit 49cc0bd162
4 changed files with 11 additions and 7 deletions
+4 -3
View File
@@ -1,4 +1,5 @@
from xml.dom.minidom import getDOMImplementation
import codecs
class XMLOutput():
def __init__(self, groups):
@@ -18,8 +19,8 @@ class XMLOutput():
xml_param.appendChild(xml_field)
xml_value = xml_document.createTextNode(value)
xml_field.appendChild(xml_value)
self.output = xml_document.toprettyxml(indent=" ", newl="\n", encoding="utf-8")
self.xml_document = xml_document
def Save(self, filename):
with open(filename, 'wb') as f:
f.write(self.output)
with codecs.open(filename, 'w', 'utf-8') as f:
self.xml_document.writexml(f, indent=" ", addindent=" ", newl="\n")