diff --git a/CHANGELOG.md b/CHANGELOG.md index f308e16d..65f3eff2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ CHANGELOG for FlatCAM Evo beta ================================================= +16.01.2023 + +- fixed an encoding error in the Excellon parser + 20.05.2022 - small fix for a bug that interfere with running the 2D graphic mode diff --git a/appParsers/ParseExcellon.py b/appParsers/ParseExcellon.py index 06061556..5d1a60a6 100644 --- a/appParsers/ParseExcellon.py +++ b/appParsers/ParseExcellon.py @@ -230,9 +230,20 @@ class Excellon(Geometry): else: if filename is None: return "fail" - efile = open(filename, 'r') - estr = efile.readlines() - efile.close() + + estr = "" + decoded = False + encodings_types = ('cp1252', 'cp850', 'utf-8', 'utf8') + for enc in encodings_types: + try: + with open(filename, 'r', encoding=enc) as efile: + estr = efile.readlines() + decoded = True + break + except UnicodeDecodeError: + pass + if decoded is False: + return 'fail' try: self.parse_lines(estr)