aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Herrmann <adrian.herrmann@qt.io>2022-09-27 20:31:51 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-09-29 17:46:02 +0000
commit0ac095f9a2bfeffc9a155cef5ce57e00674e643a (patch)
treea27a4302e32310bb26fcdea950b73d033c6b0bb2
parent296b3453c7f9e80750b930b10989be8a3a82fce9 (diff)
example_gallery: Switch to UTF-8 encoding
Switch the encoding when reading example-related files (code, rst, pyproject etc.) to UTF-8 to enable special characters and 😊. Change-Id: I6737875bc9b64d069b8adc478912f4ab4567e28e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit 81d81baf0ef6c42ebdb6a2b2293d09031ce6dd5c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--tools/example_gallery/main.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/tools/example_gallery/main.py b/tools/example_gallery/main.py
index 3dab597f2..7e69c36fe 100644
--- a/tools/example_gallery/main.py
+++ b/tools/example_gallery/main.py
@@ -168,7 +168,7 @@ def get_code_tabs(files, project_dir):
_path = project_dir / project_file
_file_content = ""
try:
- with open(_path, "r") as _f:
+ with open(_path, "r", encoding="utf-8") as _f:
_file_content = remove_licenses(_f.read())
except UnicodeDecodeError as e:
print(f"example_gallery: error decoding {_path}:{e}")
@@ -276,7 +276,7 @@ if __name__ == "__main__":
files = []
try:
- with pyproject_file.open("r") as pyf:
+ with pyproject_file.open("r", encoding="utf-8") as pyf:
pyproject = json.load(pyf)
files = pyproject["files"]
except (json.JSONDecodeError, KeyError) as e:
@@ -286,11 +286,11 @@ if __name__ == "__main__":
if files:
rst_file_full = EXAMPLES_DOC / rst_file
- with open(rst_file_full, "w") as out_f:
+ with open(rst_file_full, "w", encoding="utf-8") as out_f:
if has_doc:
doc_rst = original_doc_dir / f"{example_name}.rst"
- with open(doc_rst) as doc_f:
+ with open(doc_rst, encoding="utf-8") as doc_f:
content_f = doc_f.read()
# Copy other files in the 'doc' directory, but