D:/software/git/install/copy and /export to clipboard produce garbled Chinese characters on Windows
Description
On Windows (Chinese locale), using /copy or /export (to clipboard) results in garbled Chinese characters (mojibake). Exporting to a file with /export works correctly — the file contains proper UTF-8 encoded Chinese text.
Environment
- OS: Windows 11 Home China 10.0.26200
- Shell: bash (Git Bash)
- System locale: Chinese (Simplified), default code page GBK (CP936)
- Claude Code version: latest
Steps to Reproduce
- Have Claude respond with Chinese characters (e.g. any conversation in Chinese)
- Run
/copy 1to copy the last response to clipboard - Paste into any editor — Chinese characters are garbled
- Alternatively, run
/export(to clipboard) — same garbled result - Run
/export(to file) — file opens correctly with proper Chinese text
Expected Behavior
Clipboard content should preserve UTF-8 encoded Chinese characters correctly, same as file export.
Root Cause Analysis
The clipboard command used on Windows (likely clip.exe) reads stdin using the console's active code page (GBK/CP936 on Chinese Windows), but Claude Code outputs UTF-8 text. The encoding mismatch causes mojibake.
Suggested Fix
Use PowerShell's Set-Clipboard with explicit UTF-8 handling, for example:
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$input | Set-Clipboard
Or use win32clipboard / native Windows API to write UTF-8 text directly to the clipboard.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗