Skip to content

Commit

Permalink
fixes 0003865: non-ASCII characters incorrectly displayed in material…
Browse files Browse the repository at this point in the history
… cards

The combination Py2+Qt5 already worked, this change now fixes the combinations Py2+Qt4 and Py3+Qt5
  • Loading branch information
wwmayer committed Feb 26, 2019
1 parent 29ae44e commit 070a153
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/Mod/Material/importFCMat.py
Expand Up @@ -103,17 +103,26 @@ def read(filename):
filename = filename.encode(sys.getfilesystemencoding())
# print(filename)
card_name_file = os.path.splitext(os.path.basename(filename))[0]
f = pythonopen(filename)
if sys.version_info.major >= 3:
f = pythonopen(filename, encoding="utf8")
else:
f = pythonopen(filename)
d = {}
d["CardName"] = card_name_file # CardName is the MatCard file name
ln = 0
for line in f:
if ln == 0:
card_name_content = line.split(";")[1].strip() # Line 1
v = line.split(";")[1].strip() # Line 1
if hasattr(v, "decode"):
v = v.decode('utf-8')
card_name_content = v
if card_name_content != d["CardName"]:
FreeCAD.Console.PrintError("File CardName (" + card_name_file + ") is not content CardName (" + card_name_content + ")\n")
elif ln == 1:
d["AuthorAndLicense"] = line.split(";")[1].strip() # Line 2
v = line.split(";")[1].strip() # Line 2
if hasattr(v, "decode"):
v = v.decode('utf-8')
d["AuthorAndLicense"] = v
else:
# ; is a Commend
# # might be a comment too ?
Expand Down

0 comments on commit 070a153

Please sign in to comment.