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)