UTF8 Encoding #2218

Open
opened 2026-02-16 17:34:43 -05:00 by yindo · 6 comments
Owner

Originally created by @LexBoosT on GitHub (Oct 21, 2025).

Question

hello, I would like that on certain script I could be able to save the file in utf8 with BOM instead of utf8 only. how can I do it please?

Originally created by @LexBoosT on GitHub (Oct 21, 2025). ### Question hello, I would like that on certain script I could be able to save the file in utf8 with BOM instead of utf8 only. how can I do it please?
Author
Owner

@rekram1-node commented on GitHub (Oct 21, 2025):

u want opencode to create non utf8 files, is that correct (or the option to) via BOM

@rekram1-node commented on GitHub (Oct 21, 2025): u want opencode to create non utf8 files, is that correct (or the option to) via BOM
Author
Owner

@LexBoosT commented on GitHub (Oct 21, 2025):

Yes because when an AI makes a modification to a script, this one, opencode modifies the encoding to UTF8, and I would like this to keep the encoding of the file which it was in UTF8 with Bom

@LexBoosT commented on GitHub (Oct 21, 2025): Yes because when an AI makes a modification to a script, this one, opencode modifies the encoding to UTF8, and I would like this to keep the encoding of the file which it was in UTF8 with Bom
Author
Owner

@rekram1-node commented on GitHub (Oct 21, 2025):

gotcha

@rekram1-node commented on GitHub (Oct 21, 2025): gotcha
Author
Owner

@renanfranca commented on GitHub (Jan 22, 2026):

I am interested in that feature too. In my case, I am working on a project encoded with ISO-8859-1. Every time a file is edited, it transforms the file into UTF-8. I tried to turn the formatter option to false (https://opencode.ai/docs/formatters/#disabling-formatters)

@renanfranca commented on GitHub (Jan 22, 2026): I am interested in that feature too. In my case, I am working on a project encoded with `ISO-8859-1`. Every time a file is edited, it transforms the file into `UTF-8`. I tried to turn the formatter option to `false` (https://opencode.ai/docs/formatters/#disabling-formatters)
Author
Owner

@13640535881 commented on GitHub (Feb 12, 2026):

Any progress?

@13640535881 commented on GitHub (Feb 12, 2026): Any progress?
Author
Owner

@Mikael-Gustavsson commented on GitHub (Feb 16, 2026):

This issue is actually bigger than it suggests: OpenCode corrupts PowerShell files

OpenCode strips UTF-8 BOM when editing files, which breaks PowerShell scripts with international characters (å, ä, ö, etc.). PowerShell requires UTF-8 BOM to correctly interpret non-ASCII characters.

Reproduction:

example.ps1 (UTF-8 with BOM)
Write-Host "Börjar bearbetning..."

  • Before OpenCode edit: file example.ps1 → "UTF-8 (with BOM)" ✓ works
  • After OpenCode edit: file example.ps1 → "UTF-8" (no BOM) ✗ shows gibberish

Any edit to a PowerShell file removes the BOM and corrupts the script, making OpenCode unusable for PowerShell development in non-English environments.

Expected:

  • Preserve UTF-8 BOM for .ps1/.psm1/.psd1 files.
@Mikael-Gustavsson commented on GitHub (Feb 16, 2026): ## This issue is actually bigger than it suggests: OpenCode **corrupts PowerShell files** OpenCode strips UTF-8 BOM when editing files, which breaks PowerShell scripts with international characters (å, ä, ö, etc.). PowerShell requires UTF-8 BOM to correctly interpret non-ASCII characters. ## Reproduction: `example.ps1` (UTF-8 with BOM) `Write-Host "Börjar bearbetning..."` * Before OpenCode edit: file example.ps1 → "UTF-8 (with BOM)" ✓ works * After OpenCode edit: file example.ps1 → "UTF-8" (no BOM) ✗ shows gibberish Any edit to a PowerShell file removes the BOM and corrupts the script, making OpenCode unusable for PowerShell development in non-English environments. # Expected: * Preserve UTF-8 BOM for .ps1/.psm1/.psd1 files.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2218