fixes 0003865: non-ASCII characters incorrectly displayed in material cards
The combination Py2+Qt5 already worked, this change now fixes the combinations Py2+Qt4 and Py3+Qt5
This commit is contained in:
@@ -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 ?
|
||||
|
||||
Reference in New Issue
Block a user