Windows (zh-CN, ACP 936): terminal-selection annotations save CJK text as mojibake
Environment
- herdr 0.9.3 (Windows 11 x86_64, system UI culture zh-CN)
- plugin:
plannotator/herdr-annotate/windows-full@ c5e565e9bdbb52d152ad15169f38ed8bae31b610 - console code page: 936 (default for zh-CN). No system-wide UTF-8 beta enabled.
- shell profile does not touch encoding;
LANG/PYTHONIOENCODINGirrelevant here.
What happens
- Select Chinese text in a pane,
prefix+a, type a Chinese comment,Ctrl+S. - The annotation is saved (good — it lands in
%LOCALAPPDATA%\herdr\plugins\annotate\annotations.jsonl). - But the stored text is mojibake: the selected text and the comment are both decoded with the ANSI code page instead of UTF-8.
Real record from my machine (one line of annotations.jsonl):
{"selectedText":"# Annotations on terminal selections\r\n\r\n## Annotation 1 (Code / 1)\r\nComment on:\r\n```\r\n# Annotations on terminal selections\r\n\r\n## Annotation 1 (Code / 1)\r\nComment on: \"������\"\r\n> 测试\r\n...
测试 (the comment I typed, in the popover) survived — it was typed through the popover input. The ������ is the selected terminal text, which came from herdr as ACP-encoded bytes and was treated as UTF-8 (or the reverse), so it round-trips as replacement characters.
So the split is:
- text typed into the popover: preserved
- text captured from the terminal selection: mangled for any non-ASCII content
Notes that may narrow it down
- Document review path (
plannotator-tuiin thedocentrypoint) renders CJK correctly — I opened it withherdr plugin action invoke open --plugin annotateand the Chinese table inAGENTS.mddisplayed fine. So the TUI is OK; the problem looks specific toherdr-annotate.exe capture/ the selection text path. - The doc-review pane was launched by me from a CLI process with a clean environment. When the same pane is opened through the keybinding from the herdr server, the user reported Chinese not rendering. Environment difference between those two launch paths may be worth a look (the server inherits a different
PSModulePathon this machine, FWIW). - Related to the earlier fix "keep non-ascii text intact through the windows clipboard" — this looks like the same class of issue, on the selection-in path rather than the clipboard-out path.
Expected
Chinese (and any non-ASCII) selected text should be preserved byte-for-byte in the saved annotation, and should render correctly when copied back out as feedback.
Ask
Is the intended behavior to treat herdr's selection payload as UTF-8 unconditionally on Windows, or should the plugin read the console code page? Happy to test a patch if you point at the right spot.
Thanks @Ody123zhou. The fix from #74 now ships in helper 0.2.1 / plugin 0.9.2, so update the plugin and selections keep Chinese text. Please reopen if it still shows.