From 4610eca508949151d53417d9cbd7e04a99613c2c Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Wed, 9 May 2018 16:34:24 -0800 Subject: [PATCH] Try utf-16 if utf-8 fails --- exts/imports/process_files.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/exts/imports/process_files.py b/exts/imports/process_files.py index 0d449f1..58e3611 100644 --- a/exts/imports/process_files.py +++ b/exts/imports/process_files.py @@ -95,7 +95,7 @@ def process_files(z) -> (ConfigParser, ConfigParser, list): # Clean the Game.ini file, removing unnecessary lines try: with open(f'{path}{filename}', encoding='utf-8') as file: - game_config = process_file(file, 'game.ini', 'utf-8') + game_config = process_file(file, 'game.ini') mods = check_for_mods(file) except UnicodeDecodeError as e: print(e) @@ -104,7 +104,7 @@ def process_files(z) -> (ConfigParser, ConfigParser, list): contents = file.read() file.write(contents.decode('utf-16-le').encode('utf-8')) with open(f'{path}{filename}', encoding='utf-8') as file: - game_config = process_file(file, 'game.ini', 'utf-16-le') + game_config = process_file(file, 'game.ini') mods = check_for_mods(file) except UnicodeDecodeError as e: print(e) @@ -114,7 +114,7 @@ def process_files(z) -> (ConfigParser, ConfigParser, list): print(filename) try: with open(f'{path}{filename}', encoding='utf-8') as file: - dino_data[filename] = process_file(file, 'dino.ini', 'utf-8') + dino_data[filename] = process_file(file, 'dino.ini') except UnicodeDecodeError as e: print(e) try: @@ -122,7 +122,7 @@ def process_files(z) -> (ConfigParser, ConfigParser, list): contents = file.read() file.write(contents.decode('utf-16-le').encode('utf-8')) with open(f'{path}{filename}', encoding='utf-8') as file: - dino_data[filename] = process_file(file, 'dino.ini', 'utf-16-le') + dino_data[filename] = process_file(file, 'dino.ini') except UnicodeDecodeError as e: print(e) return 0, 0, 0