diff --git a/aiserver.py b/aiserver.py index cd4854ba..21689acd 100644 --- a/aiserver.py +++ b/aiserver.py @@ -7273,7 +7273,7 @@ def save(): save_name = koboldai_vars.story_name if koboldai_vars.story_name != "" else "untitled" same_story = True if os.path.exists("stories/{}".format(save_name)): - with open("stories/{}/story.json".format(save_name), "r") as settings_file: + with open("stories/{}/story.json".format(save_name), "r", encoding="utf-8") as settings_file: json_data = json.load(settings_file) if 'story_id' in json_data: same_story = json_data['story_id'] == koboldai_vars.story_id @@ -7334,7 +7334,7 @@ def saveRequest(savpath, savepins=True): # Write it try: - file = open(savpath, "w") + file = open(savpath, "w", encoding="utf-8") except Exception as e: return e try: @@ -7345,7 +7345,7 @@ def saveRequest(savpath, savepins=True): file.close() try: - file = open(txtpath, "w") + file = open(txtpath, "w", encoding="utf-8") except Exception as e: return e try: @@ -7429,7 +7429,7 @@ def loadRequest(loadpath, filename=None): # Read file contents into JSON object start_time = time.time() if(isinstance(loadpath, str)): - with open(loadpath, "r") as file: + with open(loadpath, "r", encoding="utf-8") as file: js = json.load(file) from_file=loadpath if(filename is None): diff --git a/koboldai_settings.py b/koboldai_settings.py index d85e2919..40e87ccc 100644 --- a/koboldai_settings.py +++ b/koboldai_settings.py @@ -938,7 +938,7 @@ class story_settings(settings): while os.path.exists(self.save_paths.base): try: # If the stories share a story id, overwrite the existing one. - with open(self.save_paths.story, "r") as file: + with open(self.save_paths.story, "r", encoding="utf-8") as file: j = json.load(file) if self.story_id == j["story_id"]: break @@ -960,7 +960,7 @@ class story_settings(settings): v2_path = os.path.join("stories", f"{self.story_name}_v2.json") if os.path.exists(v2_path): logger.info("Migrating v2 save") - with open(v2_path, "r") as file: + with open(v2_path, "r", encoding="utf-8") as file: v2j = json.load(file) if v2j["story_id"] == self.story_id: @@ -968,7 +968,7 @@ class story_settings(settings): else: logger.warning(f"Story mismatch in v2 migration. Existing file had story id {v2j['story_id']} but we have {self.story_id}") - with open(self.save_paths.story, "w") as file: + with open(self.save_paths.story, "w", encoding="utf-8") as file: file.write(self.to_json()) self.gamesaved = True