fix: add Windows UTF-8 encoding environment variables for terminals #10796
+115
−0
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.
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.