diff --git a/src/netcheck/cli.py b/src/netcheck/cli.py index 6eab4a0..217bb2c 100644 --- a/src/netcheck/cli.py +++ b/src/netcheck/cli.py @@ -33,6 +33,16 @@ from netcheck.probes.latency import ping_fanout, tcp_connect_rtt from netcheck.probes.traceroute import traceroute from netcheck.speed import NDT7_CONSENT_NOTICE +if sys.platform == "win32": + # A legacy console codepage (e.g. cp1251) cannot encode the emoji badges and + # Unicode punctuation this CLI prints; forcing UTF-8 here avoids a hard crash + # in rich's Windows renderer on every non-ASCII character. + for _stream in (sys.stdout, sys.stderr): + try: + _stream.reconfigure(encoding="utf-8", errors="replace") + except (AttributeError, ValueError): + pass + app = typer.Typer(add_completion=False, help="Deep network diagnostics.") console = Console() diff --git a/src/netcheck/compare.py b/src/netcheck/compare.py index ba8aa42..7dd80d4 100644 --- a/src/netcheck/compare.py +++ b/src/netcheck/compare.py @@ -117,7 +117,7 @@ def _block(title: str, changes: list[Change]) -> list[str]: if not changes: return [f"### {title}", "", "No change.", ""] return ( - [f"### {title}", "", "| Field | Before | After | Δ |", "|---|---|---|---|"] + [f"### {title}", "", "| Field | Before | After | Delta |", "|---|---|---|---|"] + [f"| {c.label} | {_fmt(c.before)} | {_fmt(c.after)} | {_fmt(c.delta)} |" for c in changes] + [""] )