Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jan 17, 2026

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:

  • Added Windows-specific UTF-8 environment variables to both VSCode terminals (Terminal.ts) and Execa terminals (ExecaTerminalProcess.ts)
  • The following environment variables are now set on Windows:
    • PYTHONIOENCODING=utf-8: Forces Python to use UTF-8 for stdin/stdout/stderr
    • PYTHONUTF8=1: Enables Python 3.7+ UTF-8 mode
    • RUBYOPT=-EUTF-8: Forces Ruby to use UTF-8 encoding

These 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

  1. Unit Tests: Added new test file Terminal.getEnv.spec.ts and updated ExecaTerminalProcess.spec.ts with tests for Windows UTF-8 environment variables
  2. Manual Testing: On a Windows system with GBK encoding (code page 936), verify that terminal output from Python and Ruby scripts displays correctly without character corruption

To run the tests:

cd src && npx vitest run integrations/terminal/__tests__/ExecaTerminalProcess.spec.ts integrations/terminal/__tests__/Terminal.getEnv.spec.ts

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

  • No documentation updates are required.

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 65001 as 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.

  • Behavior:
    • Sets Windows-specific UTF-8 environment variables in ExecaTerminalProcess.ts and Terminal.ts to prevent character corruption.
    • Environment variables set: PYTHONIOENCODING=utf-8, PYTHONUTF8=1, RUBYOPT=-EUTF-8.
  • Testing:
    • Adds ExecaTerminalProcess.spec.ts to test UTF-8 environment variable settings and preservation/override of existing variables.
    • Adds Terminal.getEnv.spec.ts to test environment variable settings for Windows and non-Windows platforms.
  • Misc:

This description was created by Ellipsis for 958d941. You can customize this summary. It will automatically update as commits are pushed.

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
@roomote
Copy link
Contributor Author

roomote bot commented Jan 17, 2026

Rooviewer Clock   See task on Roo Cloud

Reviewed the Windows UTF-8 encoding fix. Found one consistency issue to address.

  • Inconsistent platform handling: ExecaTerminalProcess.ts sets Python/Ruby UTF-8 vars unconditionally while Terminal.ts only sets them on Windows

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

Comment on lines +52 to +60
// 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",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

[BUG] In the inline terminal, the output of any command exhibits character corruption.

2 participants