Better handle non-ascii characters

This prevents the following error when using fcinfo as diff driver for WebTools Git:
(...)
  File "/usr/local/bin/fcinfo", line 89, in startElement
    print ("   " + key + " : " + val)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 17: ordinal not in range(128)
fatal: unable to read files to diff
This commit is contained in:
Patola
2018-02-25 17:57:43 -03:00
committed by Yorik van Havre
parent 0038120c91
commit 3dc0f77065

View File

@@ -86,7 +86,7 @@ class FreeCADFileHandler(xml.sax.ContentHandler):
items = self.contents.items()
items.sort()
for key,val in items:
print (" " + key + " : " + val)
print (" " + key.encode("utf-8").strip() + " : " + val.encode("utf-8").strip())
self.contents = {}
print (" Objects: ("+self.count+")")