Agent StrReplace/Write saves source files as UTF-16 LE on Windows — breaks Flutter/Dart/Java builds, forces manual recovery every edit

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

On Windows, when Cursor Agent edits files via StrReplace or Write, the file is sometimes saved as UTF-16 LE (no BOM) instead of UTF-8. Every ASCII character is followed by a null byte (U+0000), which corrupts the entire file.
This is not a project configuration issue — it is blocking daily development and significantly slowing down work.

Impact on my workflow (severity: critical)

  • Work speed is extremely slow because almost every Agent edit risks corrupting the file.
  • Errors occur repeatedly after Agent changes (not from my code logic).
  • I have to manually fix source files every time this happens.
  • I created a separate Python scan script (check_utf8_sources.py) and run it after every Agent session to find corrupted files.
  • When UTF-16 corruption occurs, my entire dev environment stops working:
    • Fluttercontrol character U+0000, compiler RangeError (index), build/hot reload fails
    • Java/backend serverillegal character '\u0000', compilation fails
    • Nothing runs until the file is recovered to UTF-8
      This is a productivity and reliability blocker, not a minor encoding annoyance.

Steps to Reproduce

  1. Open a normal UTF-8 Dart file (BOM 없음, import로 시작, hex 69 6D 70 = “imp”)
  2. Ask Cursor Agent to modify the file using StrReplace (or Write)
  3. Agent completes; file appears edited in the editor
  4. On disk, file is UTF-16 LE:
    • File size roughly doubles
    • Null bytes between characters: hex 69 00 6D 00 70 00 instead of 69 6D 70
  5. Run flutter run / dart analyze / Java compile → fails immediately

Expected Behavior

All Agent file writes (StrReplace, Write) must save as UTF-8 without BOM, regardless of file size, language (Korean), or OS.

Operating System

Windows 10/11

Version Information

CURSOR IDE

For AI issues: which model did you use?

AUTO

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hey @wise_contact,

Thanks for the report. This is a known issue with Agent Write/StrReplace saving files as UTF-16 LE on Windows.

The right thread to follow up on is here: Spending tokens to repair UTF-16 that should have been UTF-8 - #83 by mohitjain

Closing this one as a duplicate so we can keep the conversation in one place.