Open input file in binary mode an let XML parser deal with encoding.

Fixes #26
This commit is contained in:
Eduard Braun 2015-12-08 23:38:06 +01:00
parent 1a6ff29c14
commit 4eade69201
3 changed files with 28 additions and 8 deletions

View file

@ -3097,7 +3097,7 @@ def scourString(in_string, options=None):
# input is a filename
# returns the minidom doc representation of the SVG
def scourXmlFile(filename, options=None):
with open(filename) as f:
with open(filename, "rb") as f:
in_string = f.read()
out_string = scourString(in_string, options)
return xml.dom.minidom.parseString(out_string.encode('utf-8'))
@ -3235,7 +3235,7 @@ def parse_args(args=None, ignore_additional_args=False):
_options_parser.error("Input filename is the same as output filename")
if options.infilename:
infile = maybe_gziped_file(options.infilename)
infile = maybe_gziped_file(options.infilename, "rb")
# GZ: could catch a raised IOError here and report
else:
# GZ: could sniff for gzip compression here