Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
If the DOTNET_CLI_UI_LANGUAGE
or VSLANG
environment variable is set, the .NET CLI console output and input encoding changes to UTF-8, so that the code page can change to UTF-8 as well. This new behavior allows characters from languages set by those environment variables to be rendered correctly.
This change only affects Windows operating systems (the encoding was okay on other platforms). Moreover, it only applies to Windows 10 and later versions where the UI culture set by the user is non-English.
Characters in certain languages, including Chinese, German, Japanese, and Russian, would sometimes display as garbled characters or as ?
in the console. For example:
C:\>dotnet build
MSBuild version 17.3.0-preview[...] for .NET
???????????????...
Starting in .NET 7 (version 7.0.3xx) and .NET 8, characters render correctly. Both the encoding and the code page change. For example:
C:\>dotnet build
MSBuild version 17.3.0-preview[...] for .NET
正在确定要还原的项目…
Versions of Windows older than Windows 10 1909 don't fully support UTF-8 and may experience issues after this change. (Starting in .NET 8 and .NET 7.0.300 SDK, the .NET SDK no longer changes the encoding to UTF-8 on these versions, by default. To opt back into using UTF-8 even on Windows 10 versions that don't support it, use the DOTNET_CLI_FORCE_UTF8_ENCODING
environment variable.)
In addition, there was an existing bug where the SDK can affect the encoding of other commands and programs called in the same command prompt after the SDK has finished execution. Now that the SDK more frequently changes the encoding, the impact of this bug may increase. However, the bug was fixed in .NET 8 and .NET 7.0.300 SDK. For more information, see SDK no longer changes console encoding after completion.
7.0.3xx .NET 8 Preview 1
This change can affect source compatibility and binary compatibility. It's also a behavioral change.
Using the .NET CLI in non-English languages provided a poor experience.
Developers that weren't already using the VSLANG
and DOTNET_CLI_UI_LANGUAGE
variables aren't impacted. The impact should be minimal, as this language setting wouldn't have worked well in the first place due to garbled characters. Also, only developers using Windows 10 or later might be impacted, most of which are likely using version 1909 or later.
The legacy scenarios are already less likely to support the broken languages, so it's unlikely you'd want to use another language that might expose this break anyway.
VSLANG
and DOTNET_CLI_UI_LANGUAGE
to disable this change..NET feedback
.NET is an open source project. Select a link to provide feedback:
Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowTraining
Module
Format alphanumeric data for presentation in C# - Training
Explore basic methods in C# to format alphanumeric data.