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
In Windows host, use WriteConsoleW for stdout and stderr, and locale enabled print for file output (#102295)
Uses WriteConsoleW for writing to stdout and std err, and uses the locale version of vfwprintf to print to a file using the utf8 locale. This properly renders utf8 and GB18030 characters in the host output.
// String functions like vfwprintf convert wide to multi-byte characters as if wcrtomb were called - that is, using the current C locale (LC_TYPE).
27
+
// 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.
28
+
// However, WriteConsoleW will fail if the output is redirected to a file - in that case we will write to the fallbackFileHandle
29
+
DWORD output;
30
+
// GetConsoleMode returns FALSE when the output is redirected to a file, and we need to output to the fallback file handle.
0 commit comments