GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(pty): Add UTF-8 defaults for Windows PTY by Observer-GGboy · Pull Request #10489 · anomalyco/opencode

Conversation

@Observer-GGboy

@Observer-GGboy Observer-GGboy commented Jan 25, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

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:

  • Fixes OpenCode crashes during use on Windows (garbled console output) #10414 - OpenCode crashes with garbled console output on Windows
  • Fixes Chinese Characters #10486 - Chinese characters appearing incorrectly
  • Fixes Garbled characters appear after launching the program on Windows system. #9814 - Garbled characters after launching on Windows
  • Fixes 命令行模式下中文显示突然全部变成乱码 #9793 - Chinese characters displaying as garbled text (命令行模式下中文显示突然全部变成乱码)
  • Related to Ctrl+C during response causes terminal to print endless garbage and become unresponsive #10265 - Ctrl+C terminal garbage issue
  • Related to Scoop-fixes-opencode-windows-x64-garbled-output-issue-but-cause-unknown #10341 - Scoop Windows garbled output issue

Closes #10491

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Observer-GGboy added 4 commits January 25, 2026 12:41
@Observer-GGboy
fix(app): serve a valid web manifest
d4fa1a8
@Observer-GGboy
Fix app custom element typings on Windows
80683b2
Replace placeholder path with real typings so typecheck passes on Windows.
@Observer-GGboy
Fix enterprise custom element typings on Windows
95b2c45
Replace placeholder path with real typings so typecheck passes on Windows.
@Observer-GGboy
fix(pty): add UTF-8 defaults for Windows PTY
fc6d81a
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
@Observer-GGboy
Observer-GGboy requested a review from adamdotdevin as a code owner January 25, 2026 05:16
@github-actions github-actions Bot added the needs:issue label Jan 25, 2026
@github-actions

github-actions Bot commented Jan 25, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Jan 25, 2026

Copy link
Copy Markdown
Contributor

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Observer-GGboy Observer-GGboy mentioned this pull request Jan 25, 2026
Fix CJK character display issues in Windows terminals #10491
Closed
@github-actions github-actions Bot removed the needs:issue label Jan 25, 2026
@Observer-GGboy Observer-GGboy closed this Jan 25, 2026
@Observer-GGboy
Observer-GGboy deleted the fix/web-manifest-oauth-typings branch January 25, 2026 05:35
@amelvil2-ford

amelvil2-ford commented Jan 30, 2026

Copy link
Copy Markdown

@Observer-GGboy just wondering, why did you close this PR?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@01luyicheng 01luyicheng mentioned this pull request Jan 31, 2026
fix(pty): Add UTF-8 encoding defaults for Windows PTY 01luyicheng/opencode#1
Closed
1 of 4 tasks
01luyicheng pushed a commit to 01luyicheng/opencode that referenced this pull request Jan 31, 2026
01luyicheng
fix(pty): Add UTF-8 encoding defaults for Windows PTY
b85b0d3
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
@01luyicheng 01luyicheng mentioned this pull request Jan 31, 2026
fix(pty): Add UTF-8 encoding defaults for Windows PTY #11459
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@adamdotdevin adamdotdevin Awaiting requested review from adamdotdevin

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Fix CJK character display issues in Windows terminals Chinese Characters OpenCode crashes during use on Windows (garbled console output) Garbled characters appear after launching the program on Windows system. 命令行模式下中文显示突然全部变成乱码

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Observer-GGboy @amelvil2-ford
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.