claude-code - 💡(How to fix) Fix Edit tool corrupts UTF-8 BOM files on Windows (Hungarian/accented characters)

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Fix Action

Workaround

Use PowerShell with explicit encoding:

$utf8bom = New-Object System.Text.UTF8Encoding($true)
$content = [System.IO.File]::ReadAllText($path, $utf8bom)
$newContent = $content.Replace($old, $new)
[System.IO.File]::WriteAllText($path, $newContent, $utf8bom)

Code Example

$utf8bom = New-Object System.Text.UTF8Encoding($true)
$content = [System.IO.File]::ReadAllText($path, $utf8bom)
$newContent = $content.Replace($old, $new)
[System.IO.File]::WriteAllText($path, $newContent, $utf8bom)
RAW_BUFFERClick to expand / collapse

Problem

The Edit tool removes the UTF-8 BOM and corrupts multi-byte UTF-8 sequences (Hungarian accented characters / ékezetes karakterek) when saving files on Windows.

Steps to reproduce

  1. Open a .vb (VB.NET) file that has UTF-8 BOM encoding (EF BB BF) and contains Hungarian accented characters (é, á, ő, ű, ö, ü, í, ó)
  2. Use the Edit tool to make any change — even a purely ASCII change in a different part of the file
  3. After the edit, the file has:
    • BOM removed
    • Multi-byte UTF-8 sequences for accented characters replaced with U+FFFD replacement characters (EF BF BD)

Expected behavior

UTF-8 BOM and all Unicode characters should be preserved exactly as-is after an edit.

Actual behavior

  • BOM (EF BB BF) at start of file is removed
  • Hungarian accented characters (é → \xef\xbf\xbd, á → \xef\xbf\xbd, etc.) are replaced with replacement chars
  • This corrupts the source file and causes compile errors / garbled strings at runtime

Workaround

Use PowerShell with explicit encoding:

$utf8bom = New-Object System.Text.UTF8Encoding($true)
$content = [System.IO.File]::ReadAllText($path, $utf8bom)
$newContent = $content.Replace($old, $new)
[System.IO.File]::WriteAllText($path, $newContent, $utf8bom)

Environment

  • OS: Windows 11 Pro
  • File type: VB.NET source (.vb)
  • File encoding: UTF-8 with BOM
  • Affected characters: Hungarian diacritics (accented/ékezetes characters) — é á ő ű ö ü í ó

Impact

This silently corrupts source files. The corruption is not visible until the application is compiled/run, at which point UI strings show garbled text instead of the correct accented characters.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

UTF-8 BOM and all Unicode characters should be preserved exactly as-is after an edit.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Edit tool corrupts UTF-8 BOM files on Windows (Hungarian/accented characters)