You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE]:Support multiple file encodings in built-in tools such as Read, Grep, Edit, and Write #27832
I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Description
OpenCode currently seems to assume UTF-8 when using built-in tools such as Read, Grep, Edit, and Write.
This works well for modern projects, but it can cause problems in legacy codebases that contain files encoded with GB2312, GBK, Big5, EUC-KR, Shift-JIS, or other non-UTF-8 encodings.
For example, some older projects still contain source files encoded with non-UTF-8 encodings. When these files are read or edited as UTF-8, comments or string literals may become garbled. In some cases, using Edit or Write may also save the file back in a different or corrupted encoding, which can damage the original source file.
Expected behavior
It would be very helpful if OpenCode could support multiple file encodings in its built-in file tools, similar to editors like VS Code or Cursor.
Possible improvements:
Detect the original file encoding when using Read, Grep, Edit, or Write.
Decode non-UTF-8 files correctly when displaying or processing content.
Preserve the original file encoding when writing changes back.
Provide a project-level configuration option to specify the default encoding.
Optionally support explicit encoding conversion, such as GBK to UTF-8, when requested by the user.
For example:
{
"fileEncoding": "gbk"
}
Why this matters
Many real-world projects still contain legacy source files in non-UTF-8 encodings. These projects are difficult to migrate completely to UTF-8 because of historical reasons, old toolchains, or compatibility requirements.
Without proper encoding support, OpenCode may produce garbled text, fail to search content correctly, or accidentally corrupt source files during editing.
Better encoding support would make OpenCode safer and more practical for legacy codebases and international users.
Suggested behavior
Ideally, OpenCode should handle file encodings in a way similar to VS Code or Cursor:
Detect the file encoding automatically when possible.
Allow users to configure the encoding manually.
Preserve the original encoding when saving.
Avoid modifying files when the encoding cannot be safely determined.
encoding problem #7933: Bug report about encoding corruption (EUC-KR files read/written as UTF-8 by built-in tools), very similar symptoms
Please review those issues and consider whether your request is already covered. If it is, adding a "+1" or further details there may help prioritize the fix.
Activity
github-actions commentedon May 16, 2026
This issue might be a duplicate of existing issues. Please check:
Please review those issues and consider whether your request is already covered. If it is, adding a "+1" or further details there may help prioritize the fix.
expfukck commentedon May 25, 2026
希望能解决这个问题, 这个问题一直没修复!!!
github-actions commentedon Jul 25, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.