fix: add Windows UTF-8 encoding environment variables for terminals#10796
fix: add Windows UTF-8 encoding environment variables for terminals#10796roomote-v0[bot] wants to merge 1 commit intomainfrom
Conversation
This fixes character corruption in terminal output when Windows systems use non-UTF-8 encodings like GBK (code page 936). Adds the following environment variables on Windows: - PYTHONIOENCODING=utf-8: Force UTF-8 for Python stdin/stdout/stderr - PYTHONUTF8=1: Enable Python 3.7+ UTF-8 mode - RUBYOPT=-EUTF-8: Force Ruby to use UTF-8 encoding Fixes #10709
Reviewed the Windows UTF-8 encoding fix. Found one consistency issue to address.
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
| // Windows-specific UTF-8 environment variables to prevent character corruption | ||
| // when the system uses non-UTF-8 encodings like GBK (code page 936) | ||
| // See: https://github.com/RooCodeInc/Roo-Code/issues/10709 | ||
| // Python: Force UTF-8 encoding for stdin/stdout/stderr | ||
| PYTHONIOENCODING: "utf-8", | ||
| // Python 3.7+: Enable UTF-8 mode | ||
| PYTHONUTF8: "1", | ||
| // Ruby: Force UTF-8 encoding | ||
| RUBYOPT: "-EUTF-8", |
There was a problem hiding this comment.
The comment says "Windows-specific" but these environment variables are set unconditionally on all platforms. In contrast, Terminal.ts correctly guards these with process.platform === "win32". This creates inconsistent behavior: Execa terminals will set these vars on macOS/Linux while VSCode terminals will not. Consider either adding a platform check here to match Terminal.ts, or updating the comment to explain why these are intentionally set on all platforms (e.g., for consistency with the existing LANG/LC_ALL unconditional override).
Fix it with Roo Code or mention @roomote and request a fix.
|
@roomote , could you fix failing checks? |
Adds Windows-specific UTF-8 environment variables (PYTHONIOENCODING, PYTHONUTF8, RUBYOPT) to both VSCode terminals and Execa terminals to prevent character corruption when the system uses non-UTF-8 encodings like GBK (code page 936). Fixes the test failures from PR #10796 by updating TerminalRegistry tests to conditionally include the Windows-specific env vars based on the platform. Closes #10709
Related GitHub Issue
Closes: #10709
Description
This PR attempts to address Issue #10709 where terminal output exhibits character corruption on Windows systems using non-UTF-8 encodings like GBK (code page 936).
Implementation Details:
Terminal.ts) and Execa terminals (ExecaTerminalProcess.ts)PYTHONIOENCODING=utf-8: Forces Python to use UTF-8 for stdin/stdout/stderrPYTHONUTF8=1: Enables Python 3.7+ UTF-8 modeRUBYOPT=-EUTF-8: Forces Ruby to use UTF-8 encodingThese variables encourage UTF-8 encoding for common programming language runtimes, reducing character corruption when the Windows system code page is non-UTF-8.
Test Procedure
Terminal.getEnv.spec.tsand updatedExecaTerminalProcess.spec.tswith tests for Windows UTF-8 environment variablesTo run the tests:
Pre-Submission Checklist
Documentation Updates
Additional Notes
Feedback and guidance are welcome! This fix addresses encoding issues for Python and Ruby scripts. For cmd.exe/PowerShell commands that output Windows-native text (not through Python/Ruby), users may still need to manually run
chcp 65001as a workaround until a more comprehensive solution is implemented.Important
Adds Windows-specific UTF-8 environment variables to prevent character corruption in terminals, with tests to ensure correct behavior.
ExecaTerminalProcess.tsandTerminal.tsto prevent character corruption.PYTHONIOENCODING=utf-8,PYTHONUTF8=1,RUBYOPT=-EUTF-8.ExecaTerminalProcess.spec.tsto test UTF-8 environment variable settings and preservation/override of existing variables.Terminal.getEnv.spec.tsto test environment variable settings for Windows and non-Windows platforms.This description was created by
for 958d941. You can customize this summary. It will automatically update as commits are pushed.