在 2025-9-23 16:15, Kirill Makurin 写道:
That actually sounds like a better and simpler approach.

If you think about, it is possible that assert's expression contains Unicode 
characters (I have a few cases like this). I wonder if narrow I/O functions in 
old CRTs would just write UTF-8 encoded strings as-is without any special 
interpretation of its bytes. Conversion from char to wchar_t would lose them 
(in most cases interpret them as single-byte characters for the active locale, 
since all 255 bytes represent a valid character).

One potential cause of non-ASCII characters in the output of an assertion failure is the file name, which doesn't seem so uncommon:

   E:\lh_mouse\Desktop>chcp 65001
   Active code page: 65001

   E:\lh_mouse\Desktop>cat  テストファイル.c
   #include <stdio.h>
   int main() { puts(__FILE__); }

   E:\lh_mouse\Desktop>gcc テストファイル.c

   E:\lh_mouse\Desktop>a.exe
   テストファイル.c

The encoding of `__FILE__` can be controlled by `-fexec-charset=`, however unlike MSVC, the default is UTF-8 and is not meaningful for Windows consoles, unless CHCP'd like above.


--
Best regards,
LIU Hao

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to