All symptoms日本語

T04

Non-ASCII text piped to claude -p, python or git arrives as ?

Symptom

You pipe text with accents, CJK or emoji into claude -p (or python, git) and the program receives ?. No error. Claude may say the prompt looked garbled and guess.

Check it in 30 seconds

Paste into Windows PowerShell 5.1. It only creates files under your %TEMP% folder. If the last line says REPRODUCED, it happens on your machine.

$d = Join-Path $env:TEMP ('cc-trap-' + (Get-Date -Format 'yyyyMMddHHmmss')); New-Item -ItemType Directory $d -Force | Out-Null
$pyv = & python -c "import sys; print('%d.%d.%d' % sys.version_info[:3])" 2>$null
if (-not $pyv) { 'CANNOT CHECK (python not found, or only the Microsoft Store stub: install Python from python.org)' } else {
"python $pyv"
[IO.File]::WriteAllText("$d\hex.py", 'import sys; print(sys.stdin.buffer.read().strip().hex())')
$s = [string][char]0x65E5 + [char]0x672C
$h = $s | python "$d\hex.py"
"bytes=$h  (UTF-8 would be e697a5e69cac)"
if ($h -match '^(3f)+$') { 'REPRODUCED' } else { 'NOT REPRODUCED' }
}

Why it happens

Windows PowerShell 5.1 encodes text piped into native programs with $OutputEncoding, which defaults to ASCII. Anything outside ASCII becomes ?. It is a different setting from [Console]::OutputEncoding, which only affects reading output.

Fix

Put long non-ASCII text in a UTF-8 file and pipe an ASCII-only instruction to read it. Also set $OutputEncoding to UTF-8.

$OutputEncoding = New-Object System.Text.UTF8Encoding $false
'Read C:/work/prompt.md and do exactly what it says.' | claude -p

On the author's machine

bytes 3f3f (two question marks)

Author's machine: Windows 11 / Windows PowerShell 5.1.26100 / Python 3.13.7 / Claude Code 2.1.304, Japanese Windows (code page 932). Checked 2026-10-20 to 22.

If you searched for

Related

cc-win-kit bundles the parts that avoid these traps from the start: a write guard (with onFailure: block), an unattended runner, a doctor that scans your files and hook settings, CLAUDE.md templates and the full test suite.

cc-win-kit ($19 on Payhip)

Other symptoms