"""What tools/wikitool and tools/wikitool.ps1 run with the venv's Python. Running a file puts its own directory at the front of `sys.path`, so `chemenu` imports from here without `PYTHONPATH` - whose separator is `:` on POSIX and `;` on Windows, one more thing for two launchers to get right. The name deliberately does not start with `wikitool.`: the Windows Python installer can add `.PY` to `PATHEXT`, and a `tools/wikitool.py` could then be what PowerShell runs for `tools/wikitool`. stdout and stderr are set to UTF-8 here, the one file both launchers run. On Windows, Python writes into a pipe in the locale's code page (cp1252), and every harness reads its commands' output through a pipe: Git Bash passes the bytes on unchanged, and PowerShell decodes them with `[Console]::OutputEncoding`, which is UTF-8 under the harnesses (measured, Gitea #152). Without this, `Fußnoten` arrives as `Fu�noten`. A console is unaffected: Python writes to one through the Windows console API, whatever the encoding says. On Linux and macOS the locale is UTF-8 already, so nothing changes there. """ import sys from chemenu.cli import main def use_utf8_output() -> None: for stream in (sys.stdout, sys.stderr): if stream is not None and hasattr(stream, "reconfigure"): stream.reconfigure(encoding="utf-8") if __name__ == "__main__": use_utf8_output() main()