diff --git a/pyp5js/commands.py b/pyp5js/commands.py index e83ae2dc..63405ecb 100644 --- a/pyp5js/commands.py +++ b/pyp5js/commands.py @@ -35,7 +35,7 @@ def new_sketch(sketch_name, interpreter=PYODIDE_INTERPRETER, template_file="", u sketch.copy_initial_files(use_cdn=use_cdn) index_contet = get_sketch_index_content(sketch) - with open(sketch.index_html, "w") as fd: + with open(sketch.index_html, "w", encoding="utf-8") as fd: fd.write(index_contet) return sketch @@ -64,7 +64,7 @@ def compile_sketch(sketch_name, generate_index=False, index_template=None): # useful for generating the docs or debugging sketch.config.index_template = index_template index_contet = get_sketch_index_content(sketch) - with open(sketch.index_html, "w") as fd: + with open(sketch.index_html, "w", encoding="utf-8") as fd: fd.write(index_contet) cprint.info(f"{sketch.index_html.resolve()} updated") diff --git a/pyp5js/compiler.py b/pyp5js/compiler.py index ee4740e9..4d45ad54 100644 --- a/pyp5js/compiler.py +++ b/pyp5js/compiler.py @@ -35,7 +35,7 @@ def prepare(self): """ content = get_target_sketch_content(self.sketch) - with self.sketch.target_sketch.open('w') as fd: + with self.sketch.target_sketch.open('w', encoding="utf-8") as fd: fd.write(content) cprint.info(f"{self.sketch.target_sketch.resolve()} updated with sketch code") diff --git a/pyp5js/sketch.py b/pyp5js/sketch.py index cdc5c5f9..a719965e 100644 --- a/pyp5js/sketch.py +++ b/pyp5js/sketch.py @@ -77,7 +77,7 @@ def sketch_exists(self): def sketch_content(self): if not self.sketch_py.exists(): return "" - with self.sketch_py.open() as fd: + with self.sketch_py.open(encoding="utf-8") as fd: return fd.read() @property