Repository navigation
Description
Version / branch / commit
zero 0.14.0 (official linux-x64 release binary, ~/.local/bin/zero)
OS and environment
- WSL2 (Ubuntu 26.04) on Windows 11 Home, Japanese locale — system ANSI code page is CP932
- Terminal: Windows Terminal and herdr panes (reproduces in both, so it is not terminal-specific)
- No Linux clipboard utility installed:
wl-copy,xclip,xselare all absent (the default for a stock WSL Ubuntu image) clip.exeandpowershell.exeare reachable through the default WSL interop PATH
Steps to reproduce
- Start the TUI (
zero) on WSL2 with the environment above. - Have the assistant produce Japanese text in the transcript, e.g.
文字化けチェック:日本語の表示テスト. - Select that text with the mouse (the auto-copy-on-select path).
- Paste from the clipboard anywhere (a Windows app or another terminal).
A reproduction that bypasses Zero entirely and produces the same clipboard content:
$ printf '文字化けチェック' | clip.exe
# paste anywhere -> 譁・ュ怜喧縺代メ繧ァ繝・けExpected behavior
The clipboard contains the same text that was displayed and selected: 文字化けチェック.
Actual behavior
The clipboard contains CP932 mojibake: 譁・ュ怜喧縺代メ繧ァ繝・け. The terminal display is unaffected — only the copied content is corrupted. The corruption is exactly "UTF-8 bytes reinterpreted as CP932": re-encoding the pasted mojibake as CP932 and decoding the result as UTF-8 restores the original text, and the identical string can be produced with the bare printf ... | clip.exe above.
Root cause chain (v0.14.0 source)
internal/tui/transcript_selection.go→copyTranscriptSelectionCmdcallsclipboard.WriteAll(github.com/atotto/clipboard v0.1.4).- atotto/clipboard's unix
init()(clipboard_unix.go) falls back toclip.exewhenwl-copy,xclip, andxselare all absent — the stock-WSL default unless the user apt-installed one of them. writeAllpipes the Go string bytes (UTF-8) straight intoclip.exe's stdin.clip.exedecodes its stdin using the system ANSI code page — CP932 on Japanese Windows — so the UTF-8 payload is mojibaked before it reaches the Windows clipboard.clip.exeexits 0, soWriteAllreports success and the OSC52 fallback incopyTranscriptSelectionCmdnever engages.
Impact is not Japanese-only: any Windows locale whose ANSI code page cannot represent UTF-8 (all of them, unless the beta "UTF-8 worldwide language support" switch is enabled) corrupts non-ASCII text through this path the same way.
Suggested fix direction
On WSL (detect via WSL_DISTRO_NAME or /proc/version), route the copy through powershell.exe with the payload base64-encoded inside an -EncodedCommand + Set-Clipboard script, so no non-ASCII byte ever crosses the process boundary and the system code page cannot corrupt the text. Keep the current atotto/clipboard → OSC52 chain as the fallback when powershell.exe is unreachable (e.g. interop disabled or a containerized WSL), so behavior elsewhere is unchanged.
Workaround available to affected users today: sudo apt install wl-clipboard (or xclip) makes atotto/clipboard use the Linux utility instead of clip.exe, and the mojibake disappears.
Happy to implement the fix if the issue is approved.
Activity
Vasanthdev2004 commentedon Nov 28, 2026
Thanks for the report, the cause chain made this quick to check.
Confirmed from the source on main: the selection copy goes through
clipboard.WriteAll, and withwl-copy,xclip,xseland the Termux tools all missing the library settles onclip.exefor writing, which is what a stock WSL image gives it. I have not reproduced the paste myself, I have no machine with a CP932 code page, but yourprintf ... | clip.exeline shows the same result without Zero involved, and that is enough for me.Labelled
bugandissue-approved. #1247 is the fix and is in review.One thing outside this issue, in case you see it next: pasting goes the other way through
powershell.exe Get-Clipboardon the same setup, and its output is decoded on the way back. If Japanese text pasted into the TUI comes out wrong, please open a separate issue for it.professional-slacker commentedon Nov 28, 2026
@Vasanthdev2004

Thanks for looking into this!
I tested the reverse direction as well, and it works fine in my environment.