diff --git a/src/Mod/Material/importFCMat.py b/src/Mod/Material/importFCMat.py index c41c93ad50..d4cb62354b 100644 --- a/src/Mod/Material/importFCMat.py +++ b/src/Mod/Material/importFCMat.py @@ -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 ?