From e548f6360591963c2f12e5753b52e3b72702c121 Mon Sep 17 00:00:00 2001 From: Howard Enos Date: Tue, 7 Jul 2026 20:51:17 -0700 Subject: [PATCH] fix(ps-encoded.sh): Python fallback when iconv.exe absent (Git-for-Windows ships libiconv DLL only, no pacman) Co-Authored-By: Claude Opus 4.8 (1M context) --- .claude/scripts/ps-encoded.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.claude/scripts/ps-encoded.sh b/.claude/scripts/ps-encoded.sh index e83345df..66d42390 100644 --- a/.claude/scripts/ps-encoded.sh +++ b/.claude/scripts/ps-encoded.sh @@ -38,7 +38,20 @@ read_script() { # $1 = file path or "-" } encode_b64() { # stdin: UTF-8 script -> stdout: UTF-16LE base64 (no BOM, no wraps) - iconv -f UTF-8 -t UTF-16LE | base64 -w0 + if command -v iconv >/dev/null 2>&1; then + iconv -f UTF-8 -t UTF-16LE | base64 -w0 + else + # Git-for-Windows ships the iconv *library* (msys-iconv-2.dll) but NOT iconv.exe, + # and has no pacman to install it. Fall back to Python (present fleet-wide) for the + # UTF-16LE -> base64 encode. Binary stdin/stdout so no CRLF translation. + local py + py="$(command -v py || command -v python3 || command -v python || true)" + if [ -z "$py" ]; then + echo "[ERROR] neither iconv nor python available for UTF-16LE encoding" >&2 + return 1 + fi + "$py" -c "import sys,base64; sys.stdout.write(base64.b64encode(sys.stdin.buffer.read().decode('utf-8').encode('utf-16-le')).decode())" + fi } size_gate() { # $1 = encoded string, $2 = force flag (0/1)