From 8c4b1e0c65b64aa0d1f174e0ad824940720bc48d Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Mon, 2 Dec 2024 16:44:27 +0000 Subject: [PATCH 1/2] fix css encoding --- src/textual/css/stylesheet.py | 2 +- tests/css/test_mega_stylesheet.tcss | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/textual/css/stylesheet.py b/src/textual/css/stylesheet.py index fe3e3fac6e..82f4ffae77 100644 --- a/src/textual/css/stylesheet.py +++ b/src/textual/css/stylesheet.py @@ -276,7 +276,7 @@ def read(self, filename: str | PurePath) -> None: """ filename = os.path.expanduser(filename) try: - with open(filename, "rt") as css_file: + with open(filename, "rt", encoding="utf-8") as css_file: css = css_file.read() path = os.path.abspath(filename) except Exception: diff --git a/tests/css/test_mega_stylesheet.tcss b/tests/css/test_mega_stylesheet.tcss index 49fe8176ce..d0e9389acc 100644 --- a/tests/css/test_mega_stylesheet.tcss +++ b/tests/css/test_mega_stylesheet.tcss @@ -4,6 +4,13 @@ * something to here. Be creative. Do the wildest things you can think of. */ +/* +Test encoding... +古池や +蛙飛び込む +水の音 +*/ + * {} * * {} * * * {} From 19f97a7b06b64c367aa6aae19c3426263597ef5e Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Mon, 2 Dec 2024 16:51:51 +0000 Subject: [PATCH 2/2] more characters --- tests/css/test_mega_stylesheet.tcss | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/css/test_mega_stylesheet.tcss b/tests/css/test_mega_stylesheet.tcss index d0e9389acc..0900dc1626 100644 --- a/tests/css/test_mega_stylesheet.tcss +++ b/tests/css/test_mega_stylesheet.tcss @@ -6,6 +6,12 @@ /* Test encoding... + +床前明月光, +疑是地上霜。 +举头望明月, +低头思故乡。 + 古池や 蛙飛び込む 水の音