Skip to content

Commit ff6d6b9

Browse files
authored
correct encoding of generated *_ui.py files on windows system (#1837)
1 parent 126e377 commit ff6d6b9

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

plover_build_utils/setup.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,19 @@ def _build_ui(self, src):
112112

113113
subprocess.check_call(["pyside6-uic", "--from-imports", src, "-o", dst])
114114

115+
if sys.platform.startswith("win32"):
116+
platform_encoding = "cp1252"
117+
else:
118+
platform_encoding = "utf-8"
119+
115120
for hook in self.hooks:
116121
mod_name, attr_name = hook.split(":")
117122
mod = importlib.import_module(mod_name)
118123
hook_fn = getattr(mod, attr_name)
119-
with open(dst, "r") as fp:
124+
with open(dst, "r", encoding=platform_encoding) as fp:
120125
contents = fp.read()
121126
contents = hook_fn(contents)
122-
with open(dst, "w") as fp:
127+
with open(dst, "w", encoding="utf-8") as fp:
123128
fp.write(contents)
124129

125130
def _build_resources(self, src):

0 commit comments

Comments
 (0)