-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
In Windows host, use WriteConsoleW for stdout and stderr, and locale enabled print for file output #102295
Conversation
Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov |
- Move print functions to pal.windows.cpp - Rename print functions - Use va_copy on the args when passed to two functions - Add comment for why the methods are more complex
Looks like the tests are failing because WriteConsole fails when stdout or stderr is redirected, so we need to write to a file in that case. Working on the fix. |
There's a number of other string related functions in the pal that have locale variants, is there any reason not to update those to use UTF-8 everywhere in a follow-up? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a simple test we could add for this?
Maybe something similar to the below, but using DotNetBuilder
to set up the install in a directory with characters that don't work properly without the change in this PR:
public void DotNetInfo_NoSDK() |
That may depend on the specific function. For example, for things like strcmp, we do just want the ordinal comparison. If we don't need it, I'd rather not have to create/free the locale (for the printing to file/console here, I'm not concerned, since it is not 'normal' app startup - just either explicitly printing info to the terminal or verbose logs enabled). |
I believe this PR will also fix dotnet/sdk#17451 |
- move helper to anonymous namespace - add test for utf-8/GB18030 characters - add comments for why we need to use a locale
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Fixes #102174
Per #102174 (comment), this uses WriteConsoleW for writing to stdout and stderr, and the locale enabled _vfwprintf_l for writing to a file.