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
[BUG] Windows: text files in system code page encoding (GBK/Shift-JIS) produce garbled output when read as UTF-8 #31765
On non-English Windows systems, text files (including AGENTS.md) may be saved in the system's active code page encoding (e.g., GBK for Chinese, Shift-JIS for Japanese) instead of UTF-8. The fs.readFileString() function always decodes as UTF-8, producing garbled characters (mojibake) for non-UTF-8 files.
Affected code
packages/core/src/fs-util.ts - the readFileString method delegates to the platform's fs.readFileString() which assumes UTF-8.
Also packages/opencode/src/session/instruction.ts:91 - the read helper used to load AGENTS.md uses fs.readFileString(filepath).
Impact
Users who create AGENTS.md using Windows Notepad (which defaults to ANSI/GBK encoding on Chinese Windows) will see garbled text
CI/test files saved in non-UTF-8 encodings will produce corrupted output
This affects all file reading, not just instruction files
Suggested fix
Read the file as raw bytes, attempt UTF-8 decoding first, and if replacement characters (U+FFFD) are present, fall back to the system's active code page encoding detected via chcp.com.
Steps to reproduce
On a Chinese Windows system (code page 936)
Create a file with Chinese text using Notepad (saves as GBK by default)
fs.readFileString() decodes GBK bytes as UTF-8, producing garbled text like ���IJ���
Activity
github-actions commentedon Jun 10, 2026
This issue might be a duplicate of existing issues. Please check:
If your issue is distinct from these, please clarify what is different so maintainers can keep it open.