From af1396876d130b09003daadb0b76d5e050951578 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Thu, 14 Sep 2023 17:32:18 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B[bugfix]=20config=20config.json?= =?UTF-8?q?=E3=81=8CUnicode=E3=82=A8=E3=82=B9=E3=82=B1=E3=83=BC=E3=83=97?= =?UTF-8?q?=E3=81=A7=E4=BF=9D=E5=AD=98=E3=81=95=E3=82=8C=E3=82=8B=E5=95=8F?= =?UTF-8?q?=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config.py b/config.py index a47cd8b6..3c30c647 100644 --- a/config.py +++ b/config.py @@ -12,11 +12,11 @@ from models.transcription.transcription_languages import transcription_lang from models.transcription.transcription_utils import getInputDevices, getOutputDevices, getDefaultInputDevice, getDefaultOutputDevice def saveJson(path, key, value): - with open(path, "r") as fp: + with open(path, "r", encoding="utf-8") as fp: json_data = load(fp) json_data[key] = value - with open(path, "w") as fp: - dump(json_data, fp, indent=4) + with open(path, "w", encoding="utf-8") as fp: + json_dump(json_data, fp, indent=4, ensure_ascii=False) class Config: _instance = None @@ -543,13 +543,13 @@ class Config: def load_config(self): if os_path.isfile(self.PATH_CONFIG) is not False: - with open(self.PATH_CONFIG, 'r') as fp: + with open(self.PATH_CONFIG, 'r', encoding="utf-8") as fp: config = json_load(fp) for key in config.keys(): setattr(self, key, config[key]) - with open(self.PATH_CONFIG, 'w') as fp: + with open(self.PATH_CONFIG, 'w', encoding="utf-8") as fp: setter_methods = [ name for name, obj in vars(type(self)).items() if isinstance(obj, property) and obj.fset is not None @@ -557,6 +557,6 @@ class Config: config = {} for method in setter_methods: config[method] = getattr(self, method) - json_dump(config, fp, indent=4) + json_dump(config, fp, indent=4, ensure_ascii=False) config = Config() \ No newline at end of file