Codex on Windows: UTF-8/mojibake and patch-context mismatch issues

Hi everyone,

I’m using Codex on Windows across different codebases projects.

I sometimes see Codex read or display non-English UTF-8 text incorrectly as mojibake. For example, Turkish text like:

Görünen ad zorunludur

may appear in tool output as:

Görünen ad zorunludur

This becomes a practical problem when Codex tries to edit files with apply_patch. If the patch uses the mojibake text or a nearby non-ASCII comment/string as context, the patch may fail with messages like:

Failed to find expected lines

The workaround is usually to re-read the file and apply a narrower patch using ASCII-only context, or to avoid matching around localized strings/comments.

I’ve seen the same class of issue around comments, validation messages, localized strings, and other non-English text in source files.

There is also a related workflow issue: sometimes Codex says a line/comment/context “didn’t match” or that a “comment line was missed,” and the real cause seems to be encoding/context mismatch rather than the code logic itself.

Environment:

  • Windows
  • PowerShell shell
  • Codex Desktop / Codex agent
  • Repositories containing UTF-8 non-English text
  • Edits made through apply_patch

Questions:

  1. What is the recommended way to avoid mojibake/encoding issues when using Codex on Windows?
  2. Should Codex prefer ASCII-only patch context automatically when files contain localized UTF-8 strings?
  3. Is there a recommended prompt/instruction to make Codex preserve UTF-8 text and avoid using garbled non-ASCII output as patch anchors?
  4. Could Codex detect when patch failure is likely caused by encoding/context mismatch and retry with narrower ASCII-only context?

I’m trying to make file edits more reliable across multilingual codebases, especially when comments or localized strings are near the changed lines.

Thanks!

Welcome to the forum!

You are welcome to discuss Codex issues on the forum, however the official place to report and track them is the GitHub issue tracker for OpenAI Codex.

I had ChatGPT look for the closest related issue and it identified:

This does not appear to be a typical issue. Many non-English users are reporting similar problems as separate new issues, making it difficult to find an exact match for yours.

If that issue matches your problem, consider adding a :+1: reaction on the GitHub issue page itself, not just on the forum topic, as reactions on GitHub help the developers gauge impact and prioritize work.

If it is not the same issue, try searching the existing GitHub issues for a closer match. If you cannot find one, then open a new issue with as much detail as possible.