From e44dbbf248a9068106d4e6fcdfb90f08c9c67471 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Wed, 9 May 2018 15:47:53 -0800 Subject: [PATCH] Try utf-16 if utf-8 fails --- exts/imports/process_files.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/exts/imports/process_files.py b/exts/imports/process_files.py index e5104d4..072f5c3 100644 --- a/exts/imports/process_files.py +++ b/exts/imports/process_files.py @@ -101,9 +101,15 @@ def process_files(z) -> (ConfigParser, ConfigParser, list): mods = check_for_mods(z.open(filename)) elif 'DinoExport' in filename: # Get the contents of all DinoExport_*.ini files loaded into a dict - dino_data[filename] = process_file(z.open(filename), 'dino.ini') - if not dino_data[filename]: - return 0, 0, 0 + try: + dino_data[filename] = process_file(z.open(filename, encoding='utf-8'), 'dino.ini', 'utf-8') + except UnicodeDecodeError as e: + print(e) + try: + dino_data[filename] = process_file(z.open(filename, encoding='utf-16-le'), 'dino.ini', 'utf-16-le') + except UnicodeDecodeError as e: + print(e) + return 0, 0, 0 if not mods: mods = check_for_modded_dinos(dino_data, mods) return game_config, dino_data, mods