Fix garbled output when terminal isn't already UTF-8 at startup (#204)#205
Closed
logical-intent wants to merge 1 commit into
Closed
Fix garbled output when terminal isn't already UTF-8 at startup (#204)#205logical-intent wants to merge 1 commit into
logical-intent wants to merge 1 commit into
Conversation
…nontheweb#204) * Fix garbled output when terminal isn't already UTF-8 at startup (Aaronontheweb#204) Setting Console.OutputEncoding replaces Console.Out with a new TextWriter. We need to save the new TextWriter if we're going to write through it later - otherwise, if the old one was not UTF-8, any characters written through it that are out of range for its encoding will be replaced with a replacement character (e.g. U+FFFD).
ca6a272 to
702086e
Compare
Owner
lol yeah don't worry about that - that's the |
Aaronontheweb
added a commit
that referenced
this pull request
May 18, 2026
Setting Console.OutputEncoding replaces Console.Out with a new TextWriter. AnsiTerminal captured Console.Out at construction, so on a console that did not start in UTF-8 the cached writer stayed bound to the old encoding and rendered Unicode box-drawing characters as U+FFFD. - AnsiTerminal no longer caches Console.Out; the output writer is resolved on every flush via the Output property, so it always reflects the current Console.Out regardless of when the encoding was changed. - Consolidated UTF-8 encoding setup into ConsoleEnvironment.EnsureUtf8Output, invoked by the platform console, replacing three separate call sites. - Added regression tests covering writer resolution. Diagnosis and original fix by @logical-intent in #204 / #205. Closes #204
Owner
|
Superseded via #208 |
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.
Setting Console.OutputEncoding replaces Console.Out with a new TextWriter. We need to save the new TextWriter if we're going to write through it later - otherwise, if the old one was not UTF-8, any characters written through it that are out of range for its encoding will be replaced with a replacement character (e.g. U+FFFD).
Fixes #204
Changes
Re-jig
AnsiConsolectors so that we don't captureConsole.Outbefore we change the console encoding (and hence replaceConsole.Out)Checklist
(Akka.NET template ignored - I did make an effort to follow relevant guidance in the CONTRIBUTORS file but will double-check on that since I moved the code a little since then)
Latest
devBenchmarks / This PR's Benchmarks(More from the Akka.NET template here but happy to follow up if there's also benchmark guidelines here)