Skip to content

pi-coding-agent /copy command garbles Chinese characters on Windows #2347

@googao

Description

@googao

What happened?

When using the built-in /copy command to copy text containing Chinese characters to the clipboard on Windows, the pasted content shows garbled/corrupted characters instead of the original Chinese text.

Environment:

  • OS: Windows 11
  • pi version: 0.60.0
  • Terminal: Windows Terminal

Steps to Reproduce:

  1. Start pi in interactive mode
  2. Have the assistant respond with Chinese text (e.g., "你好,世界")
  3. Run /copy to copy the last assistant message
  4. Paste into any application (Notepad, browser, etc.)

Expected Behavior:
The Chinese characters should be copied correctly and paste as "你好,世界"

Actual Behavior:
The pasted text shows garbled characters (mojibake)

Root Cause Analysis:
The issue appears to be in the @mariozechner/clipboard native module (NAPI-RS/Rust based). On Windows, the clipboard API requires UTF-16 encoding, but the module may not be correctly converting UTF-8 input to UTF-16 before writing to the clipboard.

Workaround:
Using PowerShell as an alternative works correctly:

!powershell -Command "Set-Clipboard -Value 'Chinese text here'"

### Steps to reproduce

pi console output:  你好,世界

/copy

sublime text  view:  浣犲ソ锛屼笘鐣

### Expected behavior

_No response_

### Version

_No response_

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions