Skip to content

Commit

Permalink
Set utf-8 encoding for all files open's calls
Browse files Browse the repository at this point in the history
  • Loading branch information
berinhard committed Nov 1, 2021
1 parent f6c8536 commit 7e7fd7b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pyp5js/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion pyp5js/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion pyp5js/sketch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7e7fd7b

Please sign in to comment.