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

[Breaking change]: .NET SDK No Longer Changes Encoding Upon Exit #34471

Closed
2 of 3 tasks
nagilson opened this issue Mar 8, 2023 · 0 comments · Fixed by #34878
Closed
2 of 3 tasks

[Breaking change]: .NET SDK No Longer Changes Encoding Upon Exit #34471

nagilson opened this issue Mar 8, 2023 · 0 comments · Fixed by #34878
Assignees
Labels
binary incompatible Existing binaries may encounter a breaking change in behavior. breaking-change Indicates a .NET Core breaking change 🏁 Release: .NET 8 Work items for the .NET 8 release doc-idea Indicates issues that are suggestions for new topics [org][type][category] Pri1 High priority, do before Pri2 and Pri3 📌 seQUESTered Identifies that an issue has been imported into Quest.

Comments

@nagilson
Copy link
Member

nagilson commented Mar 8, 2023

Description

Also applies to 7.0.300. Work done: dotnet/sdk#30963

Similar to #34250 but the bug mentioned where the SDK changed the encoding of an entire console has been fixed. Its possible users began to rely on the SDK changing the encoding of the command line console upon exit even for other programs ran on that console, but that is incorrect behavior.

The other change is that we no longer change the encoding as mentioned in #34250 for old builds of Windows that don't officially support it, and instead require opt-in.

Version

.NET 8 Preview 3

Previous behavior

  • The SDK would change the encoding of a terminal after running a command such as dotnet build.
  • The SDK would use the UTF 8 encoding to correctly render non-en characters, but it did so on versions of windows 10 that did not officially support UTF-8, so the behavior was undefined on those versions.

New behavior

  • The SDK does not change the encoding after exit for other programs.
  • The SDK needs to be opted in to use UTF8 for windows versions which don't support it. See more below.

Type of breaking change

  • Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code may require source changes to compile successfully.
  • Behavioral change: Existing binaries may behave differently at run time.

Reason for change

First
A) We changed the encoding for older versions of windows 10 that had undefined behavior as those early builds didn't support utf-8 (builds before the Nov 2019 update.) Since it is not officially supported, we don't want this behavior by default and instead provide an opt-in.

B) We fixed dotnet/msbuild#1596 which was an existing issue in .NET 7 where the SDK affected the encoding on the console for other programs. Running the .NET SDK should not impact the output of other programs.

Recommended action

Applications that need to change the codepage can do so by running a process to invoke the chcp command on Windows. They shouldn't rely on the SDK to do so.

If you would like to keep the encoding change inside the SDK (but it still won't stay after the SDK is finished executing a command) for non-en languages in Windows 10 versions that don't officially support UTF-8, which is any build of before the Windows 10 (November 2019 update), you should set the environment variable DOTNET_CLI_FORCE_UTF8_ENCODING. This should also be mentioned here. https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables

Feature area

SDK

Affected APIs

No response


Associated WorkItem - 82741

@nagilson nagilson added doc-idea Indicates issues that are suggestions for new topics [org][type][category] breaking-change Indicates a .NET Core breaking change Pri1 High priority, do before Pri2 and Pri3 labels Mar 8, 2023
@dotnet-bot dotnet-bot added ⌚ Not Triaged Not triaged binary incompatible Existing binaries may encounter a breaking change in behavior. labels Mar 8, 2023
@gewarren gewarren added 🏁 Release: .NET 8 Work items for the .NET 8 release and removed ⌚ Not Triaged Not triaged labels Mar 9, 2023
@gewarren gewarren added the 🗺️ reQUEST Triggers an issue to be imported into Quest. label Apr 3, 2023
@github-actions github-actions bot added 📌 seQUESTered Identifies that an issue has been imported into Quest. and removed 🗺️ reQUEST Triggers an issue to be imported into Quest. labels Apr 4, 2023
@ghost ghost added the in-pr This issue will be closed (fixed) by an active pull request. label Apr 4, 2023
@ghost ghost removed the in-pr This issue will be closed (fixed) by an active pull request. label Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
binary incompatible Existing binaries may encounter a breaking change in behavior. breaking-change Indicates a .NET Core breaking change 🏁 Release: .NET 8 Work items for the .NET 8 release doc-idea Indicates issues that are suggestions for new topics [org][type][category] Pri1 High priority, do before Pri2 and Pri3 📌 seQUESTered Identifies that an issue has been imported into Quest.
Projects
No open projects
Status: Done
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants