fix: decode native output as UTF-8 on Windows, so progress bars stop mojibaking
winget draws its progress bar with UTF-8 block characters, but PowerShell decodes native output using the console codepage (437), turning each block into three Latin characters and burying the real messages. Sets [Console]::OutputEncoding to UTF-8 in install-windows.ps1, and chcp 65001 in ncp.cmd for the check marks and em-dashes ncp.py prints. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,14 @@ Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = "Stop"
|
||||
$RepoRoot = $PSScriptRoot
|
||||
|
||||
# winget draws its progress bar with U+2588/U+2592 block characters in UTF-8,
|
||||
# but PowerShell decodes a native command's output using the CONSOLE codepage
|
||||
# (437 on a US box). The three UTF-8 bytes of a block then render as "Gamma u e"
|
||||
# - the log fills with 'GubebGubeb...' mojibake and the real messages get lost
|
||||
# in it. Decoding as UTF-8 is the fix; it is per-process and does not touch the
|
||||
# user's console settings.
|
||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||
|
||||
# -- Helpers -------------------------------------------------------------------
|
||||
function Write-Step { param([string]$Msg) Write-Host "`n==> $Msg" -ForegroundColor Cyan }
|
||||
function Write-OK { param([string]$Msg) Write-Host " ok: $Msg" -ForegroundColor Green }
|
||||
|
||||
@@ -7,6 +7,13 @@ REM the machine PATH. ncp.ps1 stays for pwsh-on-Linux, where there is no PATH sh
|
||||
REM
|
||||
REM ASCII only, same rule as the .ps1 files - a test in tests/test_smoke.py enforces it.
|
||||
setlocal
|
||||
REM ncp.py pins its stdout to UTF-8 (it prints check marks and em-dashes, and a
|
||||
REM redirected stdout would otherwise raise UnicodeEncodeError). A console still
|
||||
REM on codepage 437 renders those bytes as mojibake, so switch it to UTF-8 here.
|
||||
REM ponytail: chcp changes the calling console's codepage and does not restore
|
||||
REM it on exit. Harmless in practice; if that ever matters, set the console CP
|
||||
REM from inside ncp.py with ctypes SetConsoleOutputCP instead.
|
||||
chcp 65001 >nul 2>&1
|
||||
set "ROOT=%~dp0.."
|
||||
REM System Python fallback so backup/restore work before the venv exists; those
|
||||
REM delegate to the stdlib-only bin/sync.py. Mirrors the same fallback in ncp.ps1.
|
||||
|
||||
Reference in New Issue
Block a user