From 1a5a42fc334ac9f5dc9ad0f51d50444b7e930ee1 Mon Sep 17 00:00:00 2001 From: KellyMichels Date: Wed, 30 Sep 2026 11:13:58 -0500 Subject: [PATCH] =?UTF-8?q?fix(deploy):=20decode=20the=20box's=20output=20?= =?UTF-8?q?as=20UTF-8,=20so=20progress=20bars=20are=20bars=20and=20not=20"?= =?UTF-8?q?=CE=93=C3=B6=C3=BC"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mirror of the same change in the private scripts repo: [Console]::OutputEncoding is switched to UTF-8 (no BOM) around the deploy loop and restored in a finally. PowerShell 5.1 decodes ssh's stdout with the OEM code page, where the UTF-8 bytes of a progress bar read as three characters each. Co-Authored-By: Claude Fable 5.1 --- zdeploy.ps1 | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/zdeploy.ps1 b/zdeploy.ps1 index 857f455..c619e81 100644 --- a/zdeploy.ps1 +++ b/zdeploy.ps1 @@ -1304,22 +1304,35 @@ function Invoke-ZTokensPublish { # ── Dispatch ───────────────────────────────────────────────────────────────── -foreach ($key in $Projects) { - # 'ztokens' matches the tool it runs (ztokens.cmd / ztokens.ps1). The old - # singular 'ztoken' still works so existing habits and any script that - # already calls it keep running. - if ($key -in @('ztokens', 'ztoken')) { Invoke-ZTokensPublish; continue } - $proj = Get-ZProject -Key $key - Invoke-DeployGitPull -Proj $proj # no-op unless deploy.gitPull is set - switch ([string]$proj.kind) { - "python" { Invoke-PythonDeploy -Key $key -Proj $proj -ChangeNote $Note } - "vite" { Invoke-ViteDeploy -Key $key -Proj $proj -ChangeNote $Note } - "nextjs" { Invoke-NextDeploy -Key $key -Proj $proj -ChangeNote $Note } - "edge" { Invoke-EdgeDeploy -Key $key -Proj $proj } - "docker" { Invoke-DockerDeploy -Key $key -Proj $proj } - "static" { Invoke-StaticDeploy -Key $key -Proj $proj } - default { throw "No deploy handler for kind '$($proj.kind)' (project '$key'). Add an Invoke-Deploy function in zdeploy.ps1." } +# pip, uv and docker draw progress bars with box-drawing characters: "━" is +# the bytes E2 94 81. PowerShell 5.1 decodes a native command's stdout - ssh's, +# here - with [Console]::OutputEncoding, which on Windows is the OEM code page +# (437 on this machine), where those three bytes read "Γöü". Forty per bar. +# Decode the box's output as the UTF-8 it is for the duration of the deploy, +# and put the console back in the finally so a deploy that throws does not +# leave the session changed. +$prevConsoleEncoding = [Console]::OutputEncoding +[Console]::OutputEncoding = New-Object System.Text.UTF8Encoding($false) +try { + foreach ($key in $Projects) { + # 'ztokens' matches the tool it runs (ztokens.cmd / ztokens.ps1). The old + # singular 'ztoken' still works so existing habits and any script that + # already calls it keep running. + if ($key -in @('ztokens', 'ztoken')) { Invoke-ZTokensPublish; continue } + $proj = Get-ZProject -Key $key + Invoke-DeployGitPull -Proj $proj # no-op unless deploy.gitPull is set + switch ([string]$proj.kind) { + "python" { Invoke-PythonDeploy -Key $key -Proj $proj -ChangeNote $Note } + "vite" { Invoke-ViteDeploy -Key $key -Proj $proj -ChangeNote $Note } + "nextjs" { Invoke-NextDeploy -Key $key -Proj $proj -ChangeNote $Note } + "edge" { Invoke-EdgeDeploy -Key $key -Proj $proj } + "docker" { Invoke-DockerDeploy -Key $key -Proj $proj } + "static" { Invoke-StaticDeploy -Key $key -Proj $proj } + default { throw "No deploy handler for kind '$($proj.kind)' (project '$key'). Add an Invoke-Deploy function in zdeploy.ps1." } + } } +} finally { + [Console]::OutputEncoding = $prevConsoleEncoding } # The timestamp goes through Stop-ZTracking as the FinalNote so it lands after # the tracking footer and before the trailing blank lines - the last thing on