diff --git a/imodqgis/gef/reading.py b/imodqgis/gef/reading.py index 3d4a11a..572a335 100644 --- a/imodqgis/gef/reading.py +++ b/imodqgis/gef/reading.py @@ -206,11 +206,16 @@ def __repr__(self): return f"{self.__class__.__name__}(nr={self.nr})" def __open_file(self, path): - with open(path, "r") as f: - text = f.read() - end_header = re.search(r"(?P#EOH[=\s+]+)", text).group("eoh") - - self._header, self._data = text.split(end_header) + try: + with open(path, "r") as f: + text = f.read() + except UnicodeDecodeError: + with open(path, "r", encoding='cp1252') as f: + text = f.read() + + end_header = re.search(r"(?P#EOH[=\s+]+)", text).group("eoh") + + self._header, self._data = text.split(end_header) self.parse_header() self.parse_data()