Skip to content

Commit

Permalink
Merge pull request #193 from berinhard/bugfix/utf-8-encoding
Browse files Browse the repository at this point in the history
Set utf-8 encoding for every open call
  • Loading branch information
berinhard authored Nov 2, 2021
2 parents df93918 + e0d5b31 commit 3fc1b36
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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 3fc1b36

Please sign in to comment.