Skip to content

[FEATURE]:Support file encoding parameter (e.g. GBK) in edit/write tools #37602

Closed as not planned

Description

@MasEne1

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Problem
The built-in edit and write tools always output files in UTF-8 encoding. This is problematic when working with legacy Chinese text files encoded in GBK (or other non-UTF-8 encodings like Shift-JIS, EUC-KR, etc.).
Currently, the only workaround is to run a post-processing command (e.g. iconv / Set-Content -Encoding Default) after every edit, which is cumbersome and error-prone.
Expected behavior
Add an optional encoding parameter to the edit and write tools so users can specify the desired output encoding, for example:
{ "filePath": "foo.txt", "oldString": "你好", "newString": "世界", "encoding": "gbk" }
The default should remain utf-8 to preserve backward compatibility.

Why this matters
GBK is still widely used in mainland China for legacy systems, government platforms, and embedded device logs.
Many developers working with Chinese text files need to produce GBK output while using opencode's editing capabilities.
A file-level encoding parameter eliminates fragile post-processing steps and makes the editing workflow seamless.
Suggested approach
Add a fileEncoding or encoding field (type: string) to the tool parameters.
Accept values like "utf-8", "gbk", "gb2312", "shift-jis", etc., using Node.js's iconv-lite or the native Encoding API.
Default to "utf-8" when the field is absent.
Related
PRs implementing iconv-lite or similar would likely be small and self-contained.
Happy to contribute if the direction is agreed upon.

Activity

  1. github-actions commented on Jul 18, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If your request is covered by one of these, consider adding a comment or reaction there instead.

  2. github-actions commented on Oct 18, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions