]> git.ipfire.org Git - thirdparty/gcc.git/commit
diagnostics: Fix mojibake from displaying UTF-8 on Windows consoles
authorPeter Damianov <peter0x44@disroot.org>
Fri, 19 Sep 2025 19:02:37 +0000 (20:02 +0100)
committerJonathan Yong <10walls@gmail.com>
Sun, 28 Sep 2025 01:32:43 +0000 (01:32 +0000)
commitbd352bd5923e2c259d7c80c69c11b1c9407f280d
tree35724b5a471d7403471dc86a1480b9af7f971df5
parent214372031a621fa4d20e44cb9d5db062578543d8
diagnostics: Fix mojibake from displaying UTF-8 on Windows consoles

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 used

This 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.
(mingw_utf8_str_to_utf16_str): 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 <peter0x44@disroot.org>
Signed-off-by: Jonathan Yong <10walls@gmail.com>
gcc/pretty-print.cc