diff --git a/.gnfiles/build/scripts/cmd_exec.py b/.gnfiles/build/scripts/cmd_exec.py index c2406fa..04c8050 100644 --- a/.gnfiles/build/scripts/cmd_exec.py +++ b/.gnfiles/build/scripts/cmd_exec.py @@ -5,11 +5,12 @@ # Refer to the "LICENSE" file in the root directory for more information. # import sys +import io import os import subprocess -# psutil is not a builtin module, so use it if it exists. +# `psutil` is not a builtin module, so use it if it exists. try: import psutil @@ -17,6 +18,10 @@ except ImportError: has_psutil = False +# Reconfigure stdout to use UTF-8 on Windows. +if sys.platform == "win32": + sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8") + def get_cmd_output(cmd: str, log_level: int = 0) -> tuple[int, str]: """Return (status, output) of executing cmd in a shell."""