INNER CODE UNIT · Python
_ensure_utf8_streams
416rehman/DeepZero · src/deepzero/cli.py:19
def _ensure_utf8_streams() -> None:
# deepzero prints unicode status glyphs (checkmarks, arrows, box drawing).
# on a legacy windows console or when stdout is redirected to a file, the
# default cp1252 encoding raises UnicodeEncodeError and crashes the run.
# force utf-8 with a non-fatal error handler before any Console is built.
for stream in (sys.stdout, sys.stderr):
try:
stream.reconfigure(encoding="utf-8", errors="backslashreplace")
except (AttributeError, ValueError):
# stream is not a reconfigurable TextIOWrapper (e.g. already wrapped)
pass
_ensure_utf8_streams()
console = Console()
# short name lookups for log formatting