Hey, this is a known issue with encoding when editing files via agent/StrReplace on Windows. The team is aware, and a few fixes have already shipped in recent versions.
A couple questions so we can understand what’s happening:
- What Cursor version are you on? Menu → About Cursor → Copy
- Was the file originally UTF-8, and after StrReplace the encoding changed to Windows-1252? Or was the file in a different encoding to begin with?
Similar reports from other users:
- Cursor AI edits corrupt Windows-1252 encoding in C++ projects (even when editor shows 1252)
- 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
- Encoding changing when editing EUC-KR files
For now, I’d recommend using git to revert any corrupted files git checkout -- <file> and making sure you’re on the latest Cursor version since a few encoding fixes have already been released.
Also, I get that data loss is really frustrating, but constructive bug reports help us investigate faster. The template from the system message above is exactly what we need for an effective investigation.