D:/software/git/install/copy and /export to clipboard produce garbled Chinese characters on Windows

Resolved 💬 3 comments Opened Apr 3, 2026 by cuiqyu Closed Apr 6, 2026

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

  1. Have Claude respond with Chinese characters (e.g. any conversation in Chinese)
  2. Run /copy 1 to copy the last response to clipboard
  3. Paste into any editor — Chinese characters are garbled
  4. Alternatively, run /export (to clipboard) — same garbled result
  5. 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.

View original on GitHub ↗

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