On 9/12/25 3:45 PM, 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 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.
        (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>
---
v2:
Fix linux build by moving decode_utf8_char outside of ifdef
Keep form feed

  gcc/pretty-print.cc | 132 +++++++++++++++++++++++++++++++++++++++++++-
  1 file changed, 129 insertions(+), 3 deletions(-)


Bootstrapped with native amd64 Linux without failures. Will push into master branch soon if there are no more feed backs.

Reply via email to