The AI assistant's file editing tool (search_replace) cannot preserve the original encoding (GBK/GB2312) when editing files, causing Chinese characters to become garbled

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

The AI assistant’s file editing tool (search_replace) cannot preserve the original encoding (GBK/GB2312) when editing files, causing Chinese characters to become garbled.

Steps to Reproduce

Open a JSP file with GBK encoding (file header declares charset=GBK)
Use AI assistant to perform text replacement operations
All Chinese characters in the file become garbled (displayed as ???)
Even with .vscode/settings.json configured for GBK encoding, the issue persists

Operating System

Windows 10/11

Version Information

Cursor 2.4.22

Additional Information

Reverting to Cursor 2.3.41 is normal

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hey, thanks for the report. This is a known issue: Agent in 2.4.x forces all files to be saved as UTF-8, ignoring the original encoding.

Similar reports with GBK, EUC-KR, Windows-1252:

Workarounds:

  1. Roll back to 2.3.41. A few users confirmed this fully fixes the issue.
  2. After Agent edits: bottom-right corner of the editor → click the encoding → “Reopen with Encoding” → GBK, then “Save with Encoding” → GBK.
  3. Try CTRL+K (inline edit) instead of Agent/Chat. It might break encoding less, but it’s not guaranteed.

The team is aware of the issue. Your report helps raise the priority, especially for GBK/GB2312, which are critical for Chinese legacy projects.

But the question is when it will be solved?

This is a first class BUG!!!

2 Likes

please fix this bug, fast.