How to configure the default encoding (utf-8) in Codex/VSCODE

Open 💬 5 comments Opened Dec 19, 2025 by santanaigorsg

What version of the VS Code extension are you using?

0.4.53

What subscription do you have?

Plus

Which IDE are you using?

VS Code

What platform is your computer?

Windows 11

What issue are you seeing?

Hello, I use VS Code with the Codex extension and my language is PT-BR UTF-8 WITHOUT BOM. The problem is that whenever the Codex agent encodes something, it converts it to UTF-8-WITCH BOM, and this always breaks my code. How do I configure the Codex extension in VS Code to use UTF-8 WITHOUT BOM? Would it be directly in config.toml?

What steps can reproduce the bug?

Whenever I send a command to the agent to encode it

What is the expected behavior?

_No response_

Additional information

_No response_

View original on GitHub ↗

5 Comments

Jose-Jimenez-Coder · 7 months ago

I’m experiencing same issue with the OpenAI Codex VSCode plugin. Whenever I modify files through the plugin, it automatically changes the file encoding to UTF-8 with BOM, which causes problems in my Laravel/Vue project. In addition, it alters accented characters (such as á, é, í, ó, ú, ñ) and replaces them with strange symbols, as shown in the attached image. This affects text readability and introduces unwanted encoding inconsistencies across the project files.

<img width="336" height="74" alt="Image" src="https://github.com/user-attachments/assets/c70f0136-546c-439e-a119-83ef3a45ec1a" />

c266 · 6 months ago

It is causing me headache too. Edit my PHP files and add BOM.

jiuyunjun · 5 months ago

You may consider adding an AGENTs.md file to explicitly specify that files should be opened and saved using UTF-8 encoding, which can help ensure the default encoding behavior in Codex/VSCode.

AGENTs.md is a project-level guidance file used to give instructions to AI coding agents (like Codex) about how to work in the repository—things like coding conventions, file handling rules, encoding standards, and other workflow preferences. It helps ensure consistent behavior when the agent reads or modifies files.

MovGP0 · 2 months ago

Currently it is not supported.

Workarounds

This restores file encodings after Codex changed them.

AGENTS.md

One way is to use an AGENTS.md file and a encoding-conversion script that fixes source code to use the correct encoding.

Git Hooks

Another way is to use a git hook that automatically executes an encoding-fix script:

.git/hooks/pre-commit

or if you want to version the script:

.githooks/pre-commit  # the instructions to execute the script
.githooks/fix-encoding.ps1 # the actual script (PowerShell is just an example here)

then in the pre-commit file add the instructions on how to run the script:

#!/bin/sh
powershell.exe -NoProfile -ExecutionPolicy Bypass -File .githooks/fix-encoding.ps1
[!tip] For performance resons, my scripts check which files have been changed by inspecting the git status and only fix modified files.

Git Config

You can specify the file encoding in git and git will automatically fix it for you

in .gitconfig

# encoding
*.rust text working-tree-encoding=UTF-16LE

# line endings
*.rust text eol=crlf
[!warning] this is not supported by every git implementation
MovGP0 · 2 months ago

I think codex should do the following:

  1. try to identify the file encoding based on the BOM when available
  2. try to use .gitconfig for the file encoding
  3. use the default of the Operating System for file encoding (e.g. for ANSI code pages)