GeezerVison is showing github.com — fix(pty): Add UTF-8 defaults for Windows PTY by Observer-GGboy · Pull Request #10489 · anomalyco/opencode
Conversation
Summary
Fix CJK (Chinese, Japanese, Korean) character display issues in Windows terminals by adding proper UTF-8 encoding defaults.
Problem
Windows terminals don't have UTF-8 encoding enabled by default, causing CJK characters to display as gibberish or question marks. This affects:
- Terminal output with CJK characters
- Python scripts with CJK strings
- Git operations with CJK filenames
- Any CLI tool outputting CJK text
Solution
This PR adds platform-specific UTF-8 defaults for Windows:
Environment Variables
LANG=en_US.UTF-8 - Sets locale for Unix-style tools
LC_ALL=en_US.UTF-8 - Overrides all locale categories
PYTHONUTF8=1 - Enables UTF-8 mode for Python 3.7+
PYTHONIOENCODING=utf-8 - Sets Python stdin/stdout/stderr encoding
Shell Startup Arguments
- CMD.exe: Runs
chcp 65001 to set code page to UTF-8
- PowerShell: Sets OutputEncoding and InputEncoding to UTF-8
Testing
Tested on Windows with:
- ✅ Terminal displaying Chinese characters correctly
- ✅ Python scripts printing CJK text without errors
- ✅ Git operations with CJK filenames
- ✅ CMD and PowerShell shells
Impact
- Platform: Windows only (no impact on macOS/Linux)
- Backwards Compatible: Yes (only sets defaults, can be overridden via env parameter)
- User-Visible: Yes (fixes CJK display issues)
Related Issues
This PR addresses the root cause of several Windows encoding issues:
Closes #10491
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Replace placeholder path with real typings so typecheck passes on Windows.
Replace placeholder path with real typings so typecheck passes on Windows.
Add platform-specific UTF-8 environment variables and shell startup args for better CJK character support on Windows.
- Set LANG and LC_ALL to en_US.UTF-8
- Set PYTHONUTF8 and PYTHONIOENCODING for Python scripts
- Add chcp 65001 for CMD.exe
- Configure PowerShell UTF-8 encoding
|
Thanks for your contribution!
This PR doesn't have a linked issue. All PRs must reference an existing issue.
Please:
- Open an issue describing the bug/feature (if one doesn't exist)
- Add
Fixes #<number> or Closes #<number> to this PR description
See CONTRIBUTING.md for details.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
The following comment was made by an LLM, it may be inaccurate:
Based on my search, I found one potentially related PR:
Potential Related PR
PR #10381: "fix: specify UTF-8 encoding for Buffer.toString() on Windows - Issue #10341"
#10381
Why it's related: This PR also addresses UTF-8 encoding issues on Windows. While PR #10489 focuses on PTY and environment variables for CJK character display, PR #10381 appears to address UTF-8 encoding at the Buffer level. Both are tackling Windows encoding problems and may have overlapping solutions or could benefit from coordination.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
01luyicheng
pushed a commit
to 01luyicheng/opencode
that referenced
this pull request
Jan 31, 2026
Set LC_ALL, LC_CTYPE, and LANG environment variables to C.UTF-8 on
Windows platform to fix Chinese character display issues in terminal.
Related issues:
- anomalyco#9793: Chinese characters displayed as garbled text in CLI mode
- anomalyco#9790: Process killed with garbled output when dragging terminal window
- anomalyco#9787: Occasional process killed with garbled output
- anomalyco#8410: TUI icons show as garbage characters on Windows 10
- anomalyco#7891: OpenCode TUI Chinese Text Display Issue
Related PR: anomalyco#10489
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|