Description
The /copy command in Claude Code corrupts UTF-8 characters when copying to Windows clipboard.
Environment
- OS: Windows 10/11
- Terminal: Windows Terminal / PowerShell
- Claude Code version: latest
Steps to Reproduce
- Have Claude generate text with non-ASCII characters (e.g., Romanian diacritics: ă, ț, ș, î, â)
- Include box-drawing characters (├, └, │, ─) in the output
- Use
/copy to copy the message
- Paste into any text editor
Expected Behavior
Characters should be preserved exactly as displayed in the terminal.
Actual Behavior
Characters are corrupted (mojibake):
ă → ─â
ț → ╚Ť
ș → ╚Ö
├── → ÔöťÔöÇÔöÇ
└── → ÔööÔöÇÔöÇ
Example
Original (in terminal):
Excelentă observație
├── Item 1
└── Item 2
After /copy + paste:
Excelent─â observa╚Ťie
ÔöťÔöÇÔöÇ Item 1
ÔööÔöÇÔöÇ Item 2
Root Cause
Windows clipboard uses different encoding (CP-1252 or UTF-16) than UTF-8 used in the terminal. The /copy command likely doesn't explicitly encode as UTF-8 when writing to clipboard.
Suggested Fix
Use explicit UTF-8 encoding when copying to clipboard on Windows, possibly via pyperclip with proper encoding or Windows API with CF_UNICODETEXT format.
Description
The
/copycommand in Claude Code corrupts UTF-8 characters when copying to Windows clipboard.Environment
Steps to Reproduce
/copyto copy the messageExpected Behavior
Characters should be preserved exactly as displayed in the terminal.
Actual Behavior
Characters are corrupted (mojibake):
ă→─âț→╚Ťș→╚Ö├──→ÔöťÔöÇÔöÇ└──→ÔööÔöÇÔöÇExample
Original (in terminal):
After /copy + paste:
Root Cause
Windows clipboard uses different encoding (CP-1252 or UTF-16) than UTF-8 used in the terminal. The
/copycommand likely doesn't explicitly encode as UTF-8 when writing to clipboard.Suggested Fix
Use explicit UTF-8 encoding when copying to clipboard on Windows, possibly via
pyperclipwith proper encoding or Windows API withCF_UNICODETEXTformat.