diff --git a/CHANGELOG.md b/CHANGELOG.md index 80c15590..4b3973e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Development - Add `keyIsDown` event to Transcrypt mode - [PR #187](https://github.com/berinhard/pyp5js/pull/187) - Fix bug with multiple events calls - PR #187 too - Serve JS files if `--local` flag [PR #195](https://github.com/berinhard/pyp5js/pull/195) +- Force `utf-8` as the lib's default encoding [PR #193](https://github.com/berinhard/pyp5js/pull/193) - Fix preload function bug in both modes - [PR #196](https://github.com/berinhard/pyp5js/pull/196) 0.7.0 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