Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make console output encoding support all languages #9776

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

GangWang01
Copy link
Contributor

@GangWang01 GangWang01 commented Feb 23, 2024

Fixes #9694

Context

For console logger, the message is not readable for some languages such as Korean if the system code page is not UTF-8.

Changes Made

Set console output encoding to UTF-8 to support all languages on OSes that support UTF-8.

  • On Core unconditionally set the encoding
  • On Full framework set the encoding if the OS system locale is non-English.

Testing

Test the fix with msbuild task Message/Warning that contains Chinese/Korean/Japanese using the following cases.

  • dotnet build on OS with English locale
  • msbuild.exe on OS with English locale (this requires set the env var DOTNET_CLI_UI_LANGUAGE)
  • dotnet build on OS with Chinese locale
  • msbuild.exe on OS with Chinese locale

Notes

@GangWang01 GangWang01 marked this pull request as ready for review February 23, 2024 12:12
@JanKrivanek
Copy link
Member

FYI - https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1985518 - We should guard the calls setting the Console properties (OutputEncoding/InpuitEncoding) with try-catch

@rainersigwald rainersigwald added 7.0 and removed 7.0 labels Mar 4, 2024
Copy link
Member

@JanKrivanek JanKrivanek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
Thanks for the effort!

@GangWang01 GangWang01 merged commit de77617 into dotnet:main Mar 21, 2024
9 checks passed
@GangWang01 GangWang01 deleted the consolelogger-encoding branch March 21, 2024 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a Console Logger Parameter to control the output encoding
6 participants