Agent Write/StrReplace tools output GBK-encoded files on Chinese Windows — persists in 3.0.13 even after ACP changed to 65001

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Agent mode — Write tool and StrReplace tool

Cursor version: 3.0.13 OS: Windows 11 (build 26200), Simplified Chinese locale

Description
When Agent writes or edits a file containing Chinese characters (or any non-ASCII text), the file is saved in GBK encoding instead of UTF-8. This happens silently — the content looks correct in the chat window, but the file on disk is GBK-encoded, causing UnicodeDecodeError at runtime and garbled display in the editor.

This bug was first reported for 2.4.x (#150243, #149887). It is still present in 3.0.13.

Steps to Reproduce
Use Cursor on a Simplified Chinese Windows machine (system locale zh-CN).
Ask Agent to create a new Python file with Chinese comments or strings.
Open the generated file — it displays garbled characters (乱码).
Verify with:

with open(“the_file.py”, “rb”) as f:
raw = f.read()
raw.decode(“utf-8”) # raises UnicodeDecodeError
raw.decode(“gbk”) # succeeds — confirms file is GBK
What I tried (none of these fixed it)
Attempted fix Effect
.vscode/settings.json: “files.encoding”: “utf8”, “files.autoGuessEncoding”: false
No effect on Agent writes
Windows Beta UTF-8 mode (changed system ACP from 936 → 65001, rebooted)
No effect — Agent still writes GBK
PYTHONUTF8=1 set as user-level env var
No effect
terminal.integrated.env.windows: PYTHONIOENCODING=UTF-8
No effect
.editorconfig with charset = utf-8
No effect
The fact that changing the system ACP to 65001 has no effect suggests the Agent’s file write path does not use the system default encoding at all — it appears to have a hardcoded or cached encoding that maps to GBK on zh-CN Windows regardless of system settings.

Scope of impact
After scanning the entire project, I found 12 text files (.py, .md, .json) had been silently corrupted to GBK by previous Agent sessions. Files I never manually edited.

Expected behavior
Agent-written files should always be UTF-8, matching files.encoding and the .editorconfig charset declaration.

Workaround (for others hitting this)

Detect and fix GBK-encoded files back to UTF-8

python fix_encoding.py path/to/file.py

fix_encoding.py (minimal version)

import sys
from pathlib import Path
for arg in sys.argv[1:]:
p = Path(arg)
raw = p.read_bytes()
try:
raw.decode(“utf-8”)
print(f"OK: {p}“)
except UnicodeDecodeError:
p.write_text(raw.decode(“gbk”), encoding=“utf-8”)
print(f"Fixed (GBK→UTF-8): {p}”)
This is a silent data corruption bug. Because there’s no warning when a file is written with the wrong encoding, users may not notice until a runtime error occurs — or worse, may commit corrupted files to version control. Please prioritize this fix for CJK users.

Steps to Reproduce

Use Cursor on a Simplified Chinese Windows machine (system locale zh-CN).
Ask Agent to create a new Python file with Chinese comments or strings.
Open the generated file — it displays garbled characters (乱码).
Verify with:

with open(“the_file.py”, “rb”) as f:
raw = f.read()
raw.decode(“utf-8”) # raises UnicodeDecodeError
raw.decode(“gbk”) # succeeds — confirms file is GBK

Expected Behavior

This is a silent data corruption bug. Because there’s no warning when a file is written with the wrong encoding, users may not notice until a runtime error occurs — or worse, may commit corrupted files to version control. Please prioritize this fix for CJK users.

Operating System

Windows 10/11

Version Information

Version: 3.0.13 (user setup)
VSCode Version: 1.105.1
Commit: 48a15759f53cd5fc9b5c20936ad7d79847d914b0
Date: 2026-04-07T03:05:17.114Z
Layout: editor
Build Type: Stable
Release Track: Default
Electron: 39.8.1
Chromium: 142.0.7444.265
Node.js: 22.22.1
V8: 14.2.231.22-electron.0
OS: Windows_NT x64 10.0.26200

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

This is a known issue with how Cursor’s Agent file write path handles encoding on Windows. Several fixes shipped in recent versions (most recently in March), but based on your report, the GBK-specific variant appears to persist in 3.0.13.

Other users have reported the same class of bug:

Your observation about ACP changes having no effect is consistent with how the encoding path works.

Your detailed reproduction case and workaround script are very helpful. I’ve shared this with our engineering team as an additional data point, specifically highlighting the GBK/zh-CN behavior that persists after the March encoding fixes.

For now, your Python fix script is the best workaround. You might also try creating a fresh workspace with no pre-existing GBK-encoded files to avoid the majority-detection feedback loop.

Actually, Opus 4.6 helped me to indentify the bug and provide me the fix script, costs me $10 of token at least. So I really hope u can fix this SOOOOOON, thank you~

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

When using the Agent to create new code files, everything looks correct in the chat output (Chinese characters display normally). However, after the file is written to the workspace, the actual file content becomes garbled.

Steps to Reproduce

My workspace is configured to use UTF-8 encoding.
Use the Agent to create new code files(including chinese).
The newly generated file will contain unreadable characters.
To read the file correctly, I have to open it using GBK encoding and then manually re-save it as UTF-8.
It seems that the Agent is writing files using GBK encoding instead of UTF-8, despite the workspace being configured for UTF-8.

Expected Behavior

The Agent should always write files using UTF-8 encoding, consistent with the workspace encoding. Chinese characters should be correctly preserved without requiring manual re-encoding.

Screenshots / Screen Recordings

Operating System

Windows 10/11

Version Information

Version: 3.1.14 (user setup)
VSCode Version: 1.105.1
Commit: d8673fb56ba50fda33ad78382000b519bb8acb70
Date: 2026-04-14T01:39:23.679Z
Layout: editor
Build Type: Stable
Release Track: Default
Electron: 39.8.1
Chromium: 142.0.7444.265
Node.js: 22.22.1
V8: 14.2.231.22-electron.0
OS: Windows_NT x64 10.0.26200

For AI issues: which model did you use?

Composer2 gpt-5.4 Codex-5.3

For AI issues: add Request ID with privacy disabled

3e6bae18-8b10-4626-b5fc-e0135ae057ce

Does this stop you from using Cursor

No - Cursor works, but with this issue

If possible, I kindly request a quick resolution to this issue, as it has seriously impacted our normal work efficiency. The problem is not only related to GBK encoding, but also occasionally involves a large number of “?” characters that cannot be manually corrected. The only solution is to use an agent, which has resulted in me using a significant amount of additional tokens and time.

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Cursor 3.1.15 / VS Code 1.105.1, Commit 3a67af7b780e0bfc8d32aefa96b8ff1cb8817f80, Windows 10 x64 10.0.26200, Electron 39.8.1, Node 22.22.1.

When using Composer 2 to generate or heavily edit frontend sources (e.g. .vue), hardcoded Chinese literals in the saved file are corrupted; API responses in the same app render Chinese correctly. index.html uses UTF-8. Issue appears on the write-to-disk path; fixed manually, no garbled sample retained. Please check UTF-8 handling when applying Composer patches on Windows. I can provide a minimal repro if needed.

Steps to Reproduce

Environment: Windows 10/11, Cursor 3.1.15 (Composer 2 available), default or UTF-8 file encoding for workspace.
2. Open an existing frontend project (e.g. Vue/Vite) where index.html uses <meta charset="utf-8"> and API responses display Chinese correctly at runtime.
3. Open Composer 2 (not only inline chat).
4. Ask Composer to create a NEW file, e.g. src/views/test-encoding.vue, containing:

  • A short <template> with several Chinese labels in plain text (hardcoded).
  • A <script setup> block with a few Chinese strings in ref() or constants.
  1. Apply / accept all generated changes so the file is written to disk.
  2. Open the new file in the editor (do not paste from elsewhere).
  3. Observe: Chinese in hardcoded strings appears as mojibake / wrong characters. (Previously: same project’s API-loaded Chinese still displayed correctly in the app.)
  4. Optional check: In the file, use “Reopen with Encoding” → UTF-8; if text stays wrong, bytes on disk are already corrupted, not only display.

Expected Behavior

Generated files should be saved as UTF-8; hardcoded Chinese in .vue/.js should appear correctly in the editor, same as the rest of the project.

Operating System

Windows 10/11

Version Information

Version: 3.1.15 (system setup)
VSCode Version: 1.105.1
Commit: 3a67af7b780e0bfc8d32aefa96b8ff1cb8817f80
Date: 2026-04-15T01:46:06.515Z
Layout: editor
Build Type: Stable
Release Track: Default
Electron: 39.8.1
Chromium: 142.0.7444.265
Node.js: 22.22.1
V8: 14.2.231.22-electron.0
OS: Windows_NT x64 10.0.26200

Does this stop you from using Cursor

No - Cursor works, but with this issue

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

When I use the agent to generate code, the content in the dialog box is normal, but the generated code file actually contains garbled characters.

Steps to Reproduce

Run the agent to generate the code.
Check the content displayed in the dialog box – it should appear normal and readable.
Save or open the generated code file.
Observe that the code file contains garbled characters instead of the expected code.

Expected Behavior

The code file should be generated in UTF-8 format to ensure that the Chinese characters are not garbled.

Screenshots / Screen Recordings

Operating System

Windows 10/11

Version Information

Version: 3.2.11 (user setup)
VSCode Version: 1.105.1
Commit: e9ee1339915a927dfb2df4a836dd9c8337e17cc0
Date: 2026-04-24T14:36:47.933Z
Layout: editor
Build Type: Stable
Release Track: Default
Electron: 39.8.1
Chromium: 142.0.7444.265
Node.js: 22.22.1
V8: 14.2.231.22-electron.0
OS: Windows_NT x64 10.0.26200

For AI issues: which model did you use?

composer2、gpt-5.4、codex-5.3

For AI issues: add Request ID with privacy disabled

3f0dc9ad-d5e6-42af-b16e-07dc23368d43

Additional Information

I’ve noticed that this issue has been happening for almost a month, and I hope it gets resolved soon. Until it’s fixed, my colleagues and I will likely not subscribe again, as this is a simple but productivity-draining problem. We hope it will be addressed as soon as possible.

Does this stop you from using Cursor

Yes - Cursor is unusable

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Cursor 3 (user)
In editor mode, the model output is encoded in a messy way,

Copy and extract the file to C:\Users\miriers\AppData\Roaming\Cursor\User

Generally speaking, if the agent window is opened, cursor3 will output normal code. If there is messy code output, it must be because the user.settings.json file was not generated properly when switching to editor mode
Use the following replacement
{
“terminal.integrated.profiles.windows”: {

    "PowerShell": {
        "source": "PowerShell",
        "icon": "terminal-powershell"
    },
    "Command Prompt": {
        "path": [
            "${env:windir}\\Sysnative\\cmd.exe",
            "${env:windir}\\System32\\cmd.exe"
        ],
        "args": [],
        "icon": "terminal-cmd"
    },
    "Git Bash": {
        "source": "Git Bash"
    }
}

}
After actual testing, it was found that the editor mode of cusor3 displayed random characters from the beginning

If “terminal.integrated.profiles.windows” is accidentally generated at the beginning, although no error will be reported temporarily, it will revert to a messy code mode whenever the settings are changed. Therefore, it is not stable enough

After actual testing, the cursor2 version has been found to have normal coding
terminal.integrated.profiles

{
“terminal.integrated.profiles.windows”: {

    "PowerShell": {
        "source": "PowerShell",
        "icon": "terminal-powershell"
    },
    "Command Prompt": {
        "path": [
            "${env:windir}\\Sysnative\\cmd.exe",
            "${env:windir}\\System32\\cmd.exe"
        ],
        "args": [],
        "icon": "terminal-cmd"
    },
    "Git Bash": {
        "source": "Git Bash"
    }
}

}

Steps to Reproduce

cursor 2 is normal ,i downgrade the version

Screenshots / Screen Recordings

Operating System

Windows 10/11

Version Information

Cursor 3 ide

Does this stop you from using Cursor

Yes - Cursor is unusable

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

Thanks for all the detailed reports here — this is a known issue and it’s the same root cause across every variant in this thread (GBK on Chinese Windows, Windows-1252, and UTF-16 LE elsewhere). It’s specific to the agent’s Write/StrReplace tools re-encoding non-ASCII text with the wrong charset on the write-to-disk path. The editor and terminal write paths are unaffected.

One clarification that explains why some of the fixes above didn’t work: setting files.encoding: utf8 and switching Windows to the UTF-8 locale beta does not cover the case where the agent creates a new file. That path doesn’t honor those settings, so seeing no change there is expected.

The most reliable workaround right now is to have the agent write files through the terminal instead of the Write/StrReplace tools:

  • Node: fs.writeFileSync(path, content, 'utf8')

  • PowerShell: [System.IO.File]::WriteAllText(path, content, [System.Text.UTF8Encoding]::new($false))

You can make this automatic by adding a project rule instructing the agent to create or edit files that contain non-ASCII (CJK) text via the terminal rather than the built-in file tools. For files already corrupted, the detect-and-re-decode script shared earlier in this thread is a good recovery step.

We’re tracking every report here against the same issue, which directly helps with prioritization. Appreciate the request IDs and byte-level details - they’re genuinely useful for the fix.