From b031f7c61424efe7271fc71dc7071e159d7b5ff8 Mon Sep 17 00:00:00 2001 From: fankesyooni Date: Wed, 1 Nov 2023 23:15:53 +0800 Subject: [PATCH] fix: file encoding for windows and other os --- initializer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/initializer.py b/initializer.py index e33964b..20584dd 100644 --- a/initializer.py +++ b/initializer.py @@ -5,11 +5,11 @@ import json import sys def replace_strings_in_file(file_path, replacements): - with open(file_path, 'r') as file: + with open(file_path, 'r', encoding = 'utf-8') as file: content = file.read() for key, value in replacements.items(): content = content.replace(key, value) - with open(file_path, 'w') as file: + with open(file_path, 'w', encoding = 'utf-8') as file: file.write(content) def replace_strings_in_directory(directory, replacements, extensions): @@ -20,7 +20,7 @@ def replace_strings_in_directory(directory, replacements, extensions): replace_strings_in_file(file_path, replacements) def main(): - with open('initializer.json', 'r') as json_file: + with open('initializer.json', 'r', encoding = 'utf-8') as json_file: replacements = json.load(json_file) extensions = ('.kt', '.properties', '.xml', '.gradle.kts', '.xcconfig', '.plist') replace_strings_in_directory('.', replacements, extensions)