From 8ff7609466c50511d11677cb7f67722211790bb7 Mon Sep 17 00:00:00 2001 From: tw1lac Date: Sun, 5 Nov 2023 13:33:25 +0100 Subject: [PATCH] Added better error handling for parsing strings and a setting to change default encoding --- export_mdl/import_stuff/mdx_parser/binary_reader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/export_mdl/import_stuff/mdx_parser/binary_reader.py b/export_mdl/import_stuff/mdx_parser/binary_reader.py index 432f5a0..1f3eb9a 100644 --- a/export_mdl/import_stuff/mdx_parser/binary_reader.py +++ b/export_mdl/import_stuff/mdx_parser/binary_reader.py @@ -26,12 +26,12 @@ def gets(self, size: int) -> str: return string_struct.decode(encoding=self.default_enc) except UnicodeDecodeError: for enc in constants.ENCODINGS.values(): - string = self.try_get_encoded_string(string_struct, enc) + string = self.try_get_decoded_string(string_struct, enc) if string is not None: return string return str(string_struct) - def try_get_encoded_string(self, string_struct: bytes, encoding: str): + def try_get_decoded_string(self, string_struct: bytes, encoding: str): try: return string_struct.decode(encoding=encoding) except UnicodeError: