You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dotnet.exe change the code page of the attached terminal to be 65001 (i.e UTF-8) when the standard output of the dotnet.exe process is redirected. (it does not occur with dotnet.exe of .Net 6 SDK)
Illustration:
Impact Of The Bug
This bug break our build.
The terminal code page is a global setting and changing it impacts how following process will run. In our case, it breaks our build system based on ninja. Indeed, our build system run both MSVC C++ compiler and dotnet.exe, and MSVC C++ compiler depends on the code page to decide on its stdout encoding. Having the MSVC C++ compiler encoding changing randomly in the middle of the build creates issues.
How To Visualize The Terminal Code Page
To understand the bug it is important to be able to display the current code page of the terminal. I have created simple ShowConsoleCP.exe tool to do so which call and display the result of GetConsoleCP() and GetConsoleOutputCP()'s Win32 API. The tool is available in this ReproCodePage.zip archive.
How To Reproduce The Bug
Simple way: you can run the run_repro.cmd script of ReproCodePage.zip
Detailed way:
Start a terminal
create a new dotnet project. (e.g dotnet new console HelloWorld)
visualize the current terminal code page (e.g use ShowConsoleCP.exe included in ReproCodePage.zip)
If the code page is 65001, set another code page and go back to step 3 (e.g run chcp 932)
build using dotnet and redirect its standard output. (e.g dotnet build HelloWorld > foo.txt)
Visualize the current terminal code page and noticed it is now 65001 instead of the one before
Further technical details
I have been able to reproduce the bug using various process creation api and stdout redirection:
using cmd.exe > symbol to redirect to file
using python and creation the dotnet.exe process with python's subprocess module
using Win32 API's CreateProcessA in a custom C++ application.
This bug is introduced by .Net 7 SDK. I confirmed that by uninstalling the .Net 7.0.102 SDK and getting back to .Net 6.0.113 SDK the bug described above does not occure anymore.
Bug Description
dotnet.exe change the code page of the attached terminal to be 65001 (i.e UTF-8) when the standard output of the dotnet.exe process is redirected. (it does not occur with dotnet.exe of .Net 6 SDK)
Illustration:
Impact Of The Bug
This bug break our build.
The terminal code page is a global setting and changing it impacts how following process will run. In our case, it breaks our build system based on ninja. Indeed, our build system run both MSVC C++ compiler and dotnet.exe, and MSVC C++ compiler depends on the code page to decide on its stdout encoding. Having the MSVC C++ compiler encoding changing randomly in the middle of the build creates issues.
How To Visualize The Terminal Code Page
To understand the bug it is important to be able to display the current code page of the terminal. I have created simple
ShowConsoleCP.exe
tool to do so which call and display the result ofGetConsoleCP()
andGetConsoleOutputCP()
's Win32 API. The tool is available in this ReproCodePage.zip archive.How To Reproduce The Bug
Simple way: you can run the
run_repro.cmd
script of ReproCodePage.zipDetailed way:
dotnet new console HelloWorld
)chcp 932
)dotnet
and redirect its standard output. (e.gdotnet build HelloWorld > foo.txt
)Further technical details
>
symbol to redirect to fileCreateProcessA
in a custom C++ application.dotnet --info
:The text was updated successfully, but these errors were encountered: