Bug Report: Agent Write/StrReplace tools corrupt UTF-8 Chinese text on Windows

Describe the Bug

Environment
OS: Windows 10 (10.0.19045)
Editor: Cursor (Agent mode)
Project locale: zh-CN (Chinese README and Vue SFC comments)
Affected tools: Write, StrReplace (agent file edit tools)
Summary
When the Cursor Agent uses the Write or StrReplace tool to create or modify files containing UTF-8 Chinese (CJK) text on Windows, the saved file is corrupted. Chinese characters become mojibake (e.g. ``) or U+FFFD replacement characters. The same content written via terminal (node fs.writeFileSync, PowerShell [System.IO.File]::WriteAllText with UTF-8) saves correctly.

Steps to Reproduce
On Windows 10, open any workspace in Cursor Agent mode.
Ask the agent to create a Markdown file with Chinese content, e.g.:

动态子表组件

适用于 RuoYi Vue 2.x 的动态子表面板。
Agent uses the Write tool to save README.md.
Open the file in VS Code or run Get-Content -Encoding UTF8 README.md.
Compare with the same content written via:
[System.IO.File]::WriteAllText(“README-ok.md”, $content, [System.Text.UTF8Encoding]::new($false))
Expected Behavior
File on disk is valid UTF-8; Chinese displays correctly in VS Code, git diff, and runtime.

Actual Behavior
File contains corrupted bytes. Example from ruoyi-ui/src/components/dynamic/README.md after Write tool:

DynamicEntityDetail ��̬�����

���� RuoYi Vue 2.x �Ķ�̬�ӱ������
Hex inspection shows multi-byte UTF-8 sequences were damaged during agent write path.

Workarounds (user-side)
Manual paste/save in VS Code with UTF-8 encoding
Shell: Node fs.writeFileSync(path, content, ‘utf8’)
Shell: PowerShell WriteAllText with UTF8Encoding(false)
Project rule: ban agent Write/StrReplace on Chinese .vue files
Impact
Agent cannot reliably create or edit localized documentation or Chinese UI strings on Windows
Wastes tokens on repeated workaround scripts
Risk of shipping corrupted source if user does not verify encoding
Suggested Fix
Ensure agent Write/StrReplace pipeline preserves UTF-8 end-to-end on Windows (no Latin-1/ACP re-encoding between model output and filesystem write).

Request ID
(Please paste from Chat … menu > Copy Request ID for the session where Write corrupted README.md)

Attachments
Corrupted file: ruoyi-ui/src/components/dynamic/README.md
Conversation context: dynamic table component consolidation session

Steps to Reproduce

When the Cursor Agent uses the Write or StrReplace tool to create or modify files containing UTF-8 Chinese (CJK) text on Windows, the saved file is corrupted. Chinese characters become mojibake (e.g. ``) or U+FFFD replacement characters. The same content written via terminal (node fs.writeFileSync, PowerShell [System.IO.File]::WriteAllText with UTF-8) saves correctly.

Operating System

Windows 10/11

Version Information

Manual paste/save in VS Code with UTF-8 encoding
Shell: Node fs.writeFileSync(path, content, ‘utf8’)
Shell: PowerShell WriteAllText with UTF8Encoding(false)
Project rule: ban agent Write/StrReplace on Chinese .vue files

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

3 posts were merged into an existing topic: Agent Write/StrReplace tools output GBK-encoded files on Chinese Windows — persists in 3.0.13 even after ACP changed to 65001