Skip to content

Commit ca82864

Browse files
author
Bryan Howard
committed
Add UTF-8 encoding to file operations for saving and loading graphs
1 parent acd693a commit ca82864

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

node_editor_window.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,8 @@ def on_save(self):
354354
self.update_window_title()
355355
data = self.graph.serialize()
356356
data["requirements"] = self.current_requirements
357-
with open(self.current_file_path, "w") as f:
358-
json.dump(data, f, indent=4)
357+
with open(self.current_file_path, "w", encoding="utf-8") as f:
358+
json.dump(data, f, indent=4, ensure_ascii=False)
359359
self.settings.setValue("last_file_path", self.current_file_path)
360360
self.output_log.append(f"Graph saved to {self.current_file_path}")
361361

@@ -369,8 +369,8 @@ def on_save_as(self):
369369
self.update_window_title()
370370
data = self.graph.serialize()
371371
data["requirements"] = self.current_requirements
372-
with open(self.current_file_path, "w") as f:
373-
json.dump(data, f, indent=4)
372+
with open(self.current_file_path, "w", encoding="utf-8") as f:
373+
json.dump(data, f, indent=4, ensure_ascii=False)
374374
self.settings.setValue("last_file_path", self.current_file_path)
375375
self.output_log.append(f"Graph saved to {self.current_file_path}")
376376

@@ -383,7 +383,7 @@ def on_load(self, file_path=None):
383383
self.current_file_path = file_path
384384
self.current_graph_name = os.path.splitext(os.path.basename(file_path))[0]
385385
self.update_window_title()
386-
with open(file_path, "r") as f:
386+
with open(file_path, "r", encoding="utf-8") as f:
387387
data = json.load(f)
388388
self.graph.deserialize(data)
389389
self.current_requirements = data.get("requirements", [])

0 commit comments

Comments
 (0)