Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/native/corehost/hostmisc/pal.windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ void pal::file_vprintf(FILE* f, const pal::char_t* format, va_list vl)
}

namespace {
void file_printf(FILE* fallbackFileHandle, const pal::char_t* format, ...)
{
va_list args;
va_start(args, format);
pal::file_vprintf(fallbackFileHandle, format, args);
va_end(args);
}

void print_line_to_handle(const pal::char_t* message, HANDLE handle, FILE* fallbackFileHandle) {
// String functions like vfwprintf convert wide to multi-byte characters as if wcrtomb were called - that is, using the current C locale (LC_TYPE).
// In order to properly print UTF-8 and GB18030 characters to the console without requiring the user to use chcp to a compatible locale, we use WriteConsoleW.
Expand All @@ -33,7 +41,7 @@ namespace {
{
// We use file_vprintf to handle UTF-8 formatting. The WriteFile api will output the bytes directly with Unicode bytes,
// while pal::file_vprintf will convert the characters to UTF-8.
pal::file_vprintf(fallbackFileHandle, message, va_list());
file_printf(fallbackFileHandle, _X("%s"), message);
}
else {
::WriteConsoleW(handle, message, (int)pal::strlen(message), NULL, NULL);
Expand Down
Loading