Skip to content

Commit

Permalink
Load files as UTF-8
Browse files Browse the repository at this point in the history
  • Loading branch information
wch committed Apr 23, 2024
1 parent dfbf7be commit 8f6375b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion shinylive/_app_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def read_app_files(appdir: Path, destdir: Path) -> list[FileContentJson]:

type: Literal["text", "binary"] = "text"
try:
with open(root / filename, "r") as f:
with open(root / filename, "r", encoding="utf-8") as f:
file_content = f.read()
type = "text"
except UnicodeDecodeError:
Expand Down
4 changes: 2 additions & 2 deletions shinylive/_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def shinylive_app_resources(

if json_file is not None:
json_file = Path(json_file)
with open(json_file) as f:
with open(json_file, encoding="utf-8") as f:
file_contents = json.load(f)

if json_content is not None:
Expand Down Expand Up @@ -514,7 +514,7 @@ def _pyodide_lock_data() -> PyodideLockFile:
cached, so if the file changes, it won't register until the Python session is
restarted.
"""
with open(pyodide_lock_json_file(), "r") as f:
with open(pyodide_lock_json_file(), "r", encoding="utf-8") as f:
return json.load(f)


Expand Down
2 changes: 1 addition & 1 deletion shinylive/_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ def read_file(file: str | Path, root_dir: str | Path | None = None) -> FileConte
type: Literal["text", "binary"] = "text"

try:
with open(file, "r") as f:
with open(file, "r", encoding="utf-8") as f:
file_content = f.read()
type = "text"
except UnicodeDecodeError:
Expand Down
2 changes: 1 addition & 1 deletion shinylive/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def listdir_recursive(dir: str | Path) -> list[str]:
def copy_file_and_substitute(
src: str | Path, dest: str | Path, *, replacements: Sequence[FromTo]
) -> None:
with open(src, "r") as fin:
with open(src, "r", encoding="utf-8") as fin:
in_content = fin.read()
for from_str, to_str in replacements:
in_content = in_content.replace(from_str, to_str)
Expand Down

0 comments on commit 8f6375b

Please sign in to comment.