Add the feature flag that allows users to opt out automatic UTF8 console encoding#51261
Merged
GangWang01 merged 4 commits intodotnet:mainfrom Jan 9, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for a feature flag CONSOLE_USE_DEFAULT_ENCODING that allows users to opt out of automatic UTF8 console encoding. This change is part of a fix to address issues with dotnet build and console encoding behavior.
- Adds environment variable check before setting UTF8 encoding in the main dotnet CLI entry point
- Adds the same environment variable check in the UI language override setup
- Provides users control over console encoding behavior through the
CONSOLE_USE_DEFAULT_ENCODINGflag
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Cli/dotnet/Program.cs | Wraps UTF8 console encoding setup with feature flag check |
| src/Cli/Microsoft.DotNet.Cli.Utils/UILanguageOverride.cs | Wraps console encoding logic in Setup method with feature flag check |
Contributor
|
I don't like the
|
Member
Author
|
@baronfel can you please take a look? |
baronfel
previously requested changes
Oct 15, 2025
reset review since the comments were resolved
YuliiaKovalova
added a commit
to dotnet/msbuild
that referenced
this pull request
Jan 7, 2026
…ole encoding (#12637) Fixes #11850 ### Context In non-English system especially like Japanese/Chinese, when redirecting the console output which is in UTF8 encoding to the pipe, the output is garbled. There is no way to detect the encoding of the destination. So add the feature flag that allows users to opt out automatic UTF8 console encoding. ### Changes Made Opt out automatic UTF8 console encoding by setting the environment variable `CONSOLE_USE_DEFAULT_ENCODING` to `1`. ### Testing Manually tested. For msbuild.exe <img width="1108" height="306" alt="image" src="https://github.com/user-attachments/assets/9f03eeef-dd72-4df4-9747-5f8a23796800" /> For `dotnet build`, it requires the change in SDK dotnet/sdk#51261. ### Notes --------- Co-authored-by: YuliiaKovalova <[email protected]>
YuliiaKovalova
approved these changes
Jan 8, 2026
This was referenced Jan 10, 2026
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.
As part of the fix dotnet/msbuild#12637
To fix
dotnet build, it needs to apply the feature flag in dotnet too.Here is the comparison before/after the fix.
