The agent mode may cause encoding issues

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

When the Agent generates code changes, these changes appear in a review interface, with added and deleted content highlighted in different colored lines.This allows you to check and control which changes apply to your codebase.However, if the modified code uses GB2312 encoding, Chinese text may appear garbled. This issue occurs in version 2.4.

Steps to Reproduce

Expected Behavior

agent

Screenshots / Screen Recordings

Operating System

Windows 10/11

Version Information

Version: 2.4.21 (user setup)
VSCode Version: 1.105.1
Commit: dc8361355d709f306d5159635a677a571b277bc0
Date: 2026-01-22T16:57:59.675Z
Build Type: Stable
Release Track: Default
Electron: 39.2.7
Chromium: 142.0.7444.235
Node.js: 22.21.1
V8: 14.2.231.21-electron.0
OS: Windows_NT x64 10.0.19045

For AI issues: which model did you use?

agent

For AI issues: add Request ID with privacy disabled

433dc67e-f95f-43e1-96e4-584ef699fb4b

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hi,

Thanks for posting on the Cursor forum!

To help ensure most of our users can participate in discussions, this forum is currently English only.

If you’d like, you can edit your post to translate it into English. Once it meets our guidelines, it will be automatically relisted.

Thanks for understanding!

Note: This is an automated detection system and sometimes makes mistakes. If your post is already in English, feel free to ignore this message, or just make a small edit and it will be reviewed again.

Hey, thanks for the report. This is a known issue: when Agent edits files, it always saves them as UTF-8 and ignores the original encoding (GB2312/GBK in your case).

Related thread with the same bug: It changed the file encoding format, causing the text to become garbled

Temporary workaround:

  • After Agent edits the file: bottom-right corner of the editor → click the encoding → Reopen with Encoding → GBK
  • Then Save with Encoding → GBK
  • Or try CTRL+K (inline edit) instead of Agent/Chat. It might be less likely to break encoding, but it’s not guaranteed

About 2.3 vs 2.4: Yep, a few users confirmed the issue became more noticeable after updating to 2.4. You can roll back to 2.3 if the workaround doesn’t help.

The bug is logged. Your report helps raise the priority. Let me know if the workaround doesn’t work.

1 Like

My team also encounter this issues, especially when editing old c++ code, waiting for solution

I’m experiencing the exact same issue described in this post. After updating Cursor last night, when I use Agent mode to edit ASP files encoded in GB2312/GBK, all Chinese characters become corrupted and are replaced with question marks (?).

Additional details:

  • This started happening immediately after updating Cursor last night
  • The file encoding corruption is permanent - even after using “Undo File” or “Reopen with Encoding”, the Chinese characters cannot be restored
  • The files are saved in UTF-8 after Agent edits, causing permanent corruption
  • I had been using Cursor successfully for months with GB2312 files without any issues before this update
  • My editor settings correctly specify "files.encoding": "gbk" for ASP files, but Agent mode seems to ignore this setting

Workaround:
Currently, I have to manually copy-paste code snippets from AI suggestions instead of letting Agent directly modify the files, which defeats the purpose of using Agent mode.

This is a critical issue for developers working with legacy Chinese codebases. I hope this can be fixed soon.

My Cursor version: 2.4.21
OS: macOS

Yes, the corruption of code files by the Agent is permanent. Typically, the original Chinese characters are replaced with ASCII 0x3F (or the Unicode replacement character U+FFFD), and it is impossible to restore the original text from these substituted characters. My recommendation is to revert to version 2.3.41 or another 2.3 release. Currently, after rolling back to version 2.3.41, this issue has not recurred.:grin:

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.