aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src/meshbay_node/platform.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/platform.py')
-rw-r--r--packages/meshbay-node/src/meshbay_node/platform.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/platform.py b/packages/meshbay-node/src/meshbay_node/platform.py
index 4bd8e35..80aa6ae 100644
--- a/packages/meshbay-node/src/meshbay_node/platform.py
+++ b/packages/meshbay-node/src/meshbay_node/platform.py
@@ -6,6 +6,24 @@ import shutil
import sys
from pathlib import Path
+# ── Console ──────────────────────────────────────────────────────────────────
+
+
+def force_utf8_stdio() -> None:
+ """
+ Make stdout/stderr UTF-8. A Windows console is cp1252 by default, so any
+ ``print()`` carrying a character outside it — the ``->`` arrows and em
+ dashes the CLI help and messages are full of — raises UnicodeEncodeError
+ and takes the command down with it. No effect where the streams are
+ already UTF-8 or cannot be reconfigured.
+ """
+ for stream in (sys.stdout, sys.stderr):
+ try:
+ stream.reconfigure(encoding="utf-8")
+ except (AttributeError, ValueError, OSError):
+ pass
+
+
# ── Event loop ───────────────────────────────────────────────────────────────