fix(pty): Add UTF-8 encoding defaults for Windows PTY

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:
- #9793: Chinese characters displayed as garbled text in CLI mode
- #9790: Process killed with garbled output when dragging terminal window
- #9787: Occasional process killed with garbled output
- #8410: TUI icons show as garbage characters on Windows 10
- #7891: OpenCode TUI Chinese Text Display Issue

Related PR: #10489
This commit is contained in:
01luyicheng
2026-01-31 20:56:40 +08:00
parent f834915d3f
commit b85b0d3190

View File

@@ -108,6 +108,12 @@ export namespace Pty {
TERM: "xterm-256color",
OPENCODE_TERMINAL: "1",
} as Record<string, string>
if (process.platform === "win32") {
env.LC_ALL = "C.UTF-8"
env.LC_CTYPE = "C.UTF-8"
env.LANG = "C.UTF-8"
}
log.info("creating session", { id, cmd: command, args, cwd })
const spawn = await pty()