fix(cli): switch Windows console to UTF-8 on startup - #236
Open
savvadesogle wants to merge 1 commit into
Open
Conversation
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.
Summary
On Windows, switch the console code page to UTF-8 (65001) at CLI startup so Cyrillic (and other non-ASCII) input, output and copy/paste no longer turn into mojibake.
Motivation
The Windows console defaults to the CP866 OEM code page, while Node and atomic-agent emit/consume UTF-8. The mismatch corrupts Russian text in three places at once:
╨Я╤А╨╕╨▓╨╡╤Вfor "Привет").Changes
src/cli/index.ts— addensureUtf8Console(), called at the top ofmain(). On Windows only it runschcp 65001 >nul(viaexecSync) and swallows failures (some hosts disallow changing the code page).Design constraint honored here: the fix does not touch
process.stdout/process.stderr. An earlier attempt that overrodewriteto emit raw UTF-8 bytes broke the interactive TUI (ink/readline frame rendering) — output lines "jumped" and the screen corrupted. Changing only the console code page fixes all three symptoms while leaving the stream mechanics untouched.Verification
npm run lint— clean.npm test— full suite: 20 failed / 5939 passed, identical to the pre-existingmainbaseline (same 20 environment-specific Windows failures; none introduced by this change).chcpreports65001; Russian input, output and copy/paste are correct.Notes
--use-env-proxyflag (documented separately); this change affects only the console code page.execSyncis wrapped in try/catch becausechcpcan fail on hosts that forbid changing the code page (non-interactive sessions, some terminals).