Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set utf-8 encoding for every open call #193

Merged
merged 3 commits into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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