Repository navigation
fix: decode Windows shell output in the console code page - #251
Merged
Merged
Conversation
Member
Author
|
Self-review: the change is opt-in by platform. Every new path checks platform === 'win32', so Linux/macOS keep the exact UTF-8 decode they had. On Windows the risk is a wrong fallback code page; it only kicks in after output has already proven not to be UTF-8, so the worst case is the same garbage as before, never worse. The PowerShell prefix uses UTF8Encoding without a BOM so piped output does not start with U+FEFF. The cmd prefix adds one chcp.com spawn per command (~20 ms). The decoder holds back an incomplete UTF-8 lead byte so a CP949 character split across chunks still decodes. Checked before/after on a Korean Windows PC with redrob run. |
its-janghoon
force-pushed
the
fix/winencoding
branch
from
November 13, 2026 06:00
3e1bd44 to
b10695a
Compare
Ask PowerShell, cmd and Python for UTF-8 output on Windows, and decode output that is still not UTF-8 with the system ANSI code page instead of U+FFFD.
its-janghoon
force-pushed
the
fix/winencoding
branch
from
November 13, 2026 06:06
b10695a to
4b1acb7
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What's done
Shell tool output on Korean Windows (code page 949) showed Korean as
����. The shell tool and the!user shell decoded child output as UTF-8, but PowerShell 5.1, cmd builtins and Python write to a pipe in the console/ANSI code page.Shell.utf8(shell, command): on Windows, prefixes PowerShell commands with[Console]::OutputEncoding=$OutputEncoding=[Text.UTF8Encoding]::new($false);(no BOM, same idea as Codex) and cmd commands withchcp 65001>nul&.Shell.env(): on Windows,PYTHONUTF8=1andPYTHONIOENCODING=utf-8as child env defaults. The user's own env and theshell.envplugin hook still win.Shell.decoder(): streaming UTF-8 decode. On Windows only, once a chunk is not valid UTF-8, the rest of the stream is decoded with the system ANSI code page (read once fromHKLM\...\Nls\CodePage\ACP), including a lead byte held back from the previous chunk.packages/redrob/src/tool/shell.tsand the user shell inpackages/redrob/src/session/prompt.ts.Linux and macOS: no prefix, no env change, and the decoder is the same non-fatal UTF-8 decode as
Stream.decodeText.What's not done
bashtool (packages/core/src/tool/bash.ts) is left as is; it is not the tool the engine uses today.What to review
packages/core/src/shell.ts: the new functions at the end.Intentions
Fix at the source (ask the programs for UTF-8) and keep a code-page fallback for programs that ignore it.
Verified on a Korean Windows PC (code page 949),
redrob run --format jsonwith the Redrob login, runningpython -c "print('한글 테스트')",Write-Output '한글 테스트',cmd /c echo 한글:�ѱ� ��Ʈfor all three한글 테스트/한글 테스트/한글�ѱ� ��Ʈfor all three한글 테스트/한글Also on that PC,
Shell.decoder()decodes raw CP949 bytes to한글using the registry code page.Tests:
packages/core/test/shell.test.ts13 pass (7 new). Core suite: the same 17 failures as origin/develop (ModelsDev/RedrobPlugin network fixtures), none new. Redrob suite: 3564 pass, 3 fail; 2 fail on origin/develop too, andhttpapi-v2-locationtimed out under load and passes alone.bun typecheckpasses.