C:/Program Files/Git/copy command produces garbled Unicode text on Windows (clip.exe UTF-8 issue)

Resolved 💬 3 comments Opened Feb 22, 2026 by ngocdang8311 Closed Feb 26, 2026

Bug Description

The /copy command in Claude Code produces garbled/corrupted text when the conversation contains non-ASCII characters (e.g., Vietnamese, Chinese, Japanese, emoji, etc.) on Windows.

Environment

  • OS: Windows 10/11 (MSYS2 / Git Bash)
  • Claude Code version: v2.1.50
  • Shell: bash (MSYS_NT)

Steps to Reproduce

  1. Have a conversation in Claude Code that contains Unicode characters (e.g., Vietnamese: "Tóm tắt quyền của user")
  2. Run /copy to copy the conversation to clipboard
  3. Paste anywhere (Notepad, browser, VS Code, etc.)

Expected Behavior

Pasted text should preserve Unicode characters correctly:

Tóm tắt quyền của user

Actual Behavior

Pasted text is garbled/mojibake:

Tóm tắt quyền của user

This is classic UTF-8 bytes being interpreted as CP437/Windows-1252.

Root Cause

Claude Code uses clip.exe on Windows to copy text to clipboard:

windows: ["clip"]

clip.exe does not accept UTF-8 input via stdin — it interprets input using the system's default OEM codepage (typically CP437 or CP1252). When Node.js pipes UTF-8 text to clip.exe, the encoding is misinterpreted.

Suggested Fix

Replace clip with PowerShell's Set-Clipboard which handles UTF-8 correctly:

// Instead of:
windows: ["clip"]

// Use:
windows: ["powershell", "-NoProfile", "-Command", "$input | Set-Clipboard"]

Or use chcp 65001 before piping to clip:

windows: ["cmd", "/c", "chcp 65001 >nul && clip"]

Workaround

Manually select text in the terminal and copy with Ctrl+C / right-click — this preserves encoding correctly. Only the /copy command is affected.

Additional Context

  • Direct terminal copy (select + Ctrl+C) works fine
  • The issue affects ALL non-ASCII characters, not just Vietnamese
  • pbcopy on macOS and xclip/wl-copy on Linux handle UTF-8 correctly

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗