在 2025-9-12 08:50, Jonathan Yong 写道:
On 9/10/25 3:29 AM, Peter Damianov wrote:UTF-8 characters in diagnostic output (such as the warning emoji ⚠️ used by fanalyzer) display as mojibake on Windows unless the utf8 code page is being usedThis patch adds UTF-8 to UTF-16 conversion when outputting to a console on Windows. gcc/ChangeLog: * pretty-print.cc (decode_utf8_char): Move forward declaration. (utf8_to_utf16): New function to convert UTF-8 to UTF-16. (is_console_handle): New function to detect Windows console handles. (write_all): Add UTF-8 to UTF-16 conversion for console output, falling back to WriteFile for ASCII strings and regular files. Signed-off-by: Peter Damianov <peter0...@disroot.org>
I think when writing to Windows consoles, UTF-16 should always be preferred. This can simplify the change significantly, narrowing it down into `write_all()`. It may therefore always require a temporary UTF-16 buffer, but memory allocation is cheap anyway, especially when it's compared to a syscall like `WriteFile()` or `WriteConsole()`.
-- Best regards, LIU Hao
OpenPGP_signature.asc
Description: OpenPGP digital signature