-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Open
Labels
Description
Problem
OpenCode terminals on Windows do not properly display CJK (Chinese, Japanese, Korean) characters. Instead, they appear as gibberish, question marks, or cause encoding errors.
Affected Scenarios
-
Terminal Output
$ echo "你好世界" ????? -
Python Scripts
$ python -c "print('你好')" UnicodeEncodeError: 'ascii' codec can't encode characters -
Git Operations
$ git status ?? "\346\226\346\231\230.md"
Root Cause
Windows historically uses GBK/GB2312 encoding by default, not UTF-8. This causes issues when:
- Terminal code page is not set to UTF-8 (CP65001)
- Environment variables (LANG, LC_ALL) are not configured
- Python's UTF-8 mode is not enabled
- Shell encoding (PowerShell/CMD) is not configured
Proposed Solution
Add platform-specific UTF-8 defaults for Windows PTY (pseudo-terminal) creation:
-
Environment Variables
- Set
LANG=en_US.UTF-8 - Set
LC_ALL=en_US.UTF-8 - Set
PYTHONUTF8=1(Python 3.7+) - Set
PYTHONIOENCODING=utf-8
- Set
-
Shell Startup Arguments
- CMD.exe: Run
chcp 65001to set code page to UTF-8 - PowerShell: Configure OutputEncoding and InputEncoding to UTF-8
- CMD.exe: Run
Impact
- Target Platform: Windows only (no impact on macOS/Linux)
- User-Visible: Yes (fixes CJK character display)
- Backwards Compatible: Yes (only sets defaults, users can override via env parameter)