No,`setlocale(LC_CTYPE, 0)` is not exactly same as `setlocale(LC_CTYPE, NULL)` . `setlocale(LC_CTYPE, 0)` returns a zero point , and `setlocale(LC_CTYPE, NULL)` return a error string represents the current "C" locale. But they both indeed modifies the locale in a same way. I have tested it many times and didn't find anything related in the Microsoft documents.
LIU Hao <[email protected]> 于2023年3月21日周二 17:39写道: > 在 2023/3/21 17:15, 傅继晗 写道: > > Yes,MSVCRT doesn't recognize UTF-8.After debuging,I figure out that > > setlocale(LC_CTYPE, > > ".UTF8"); is equal to setlocale(LC_CTYPE, 0); in MSVCRT. And > > setlocale(LC_CTYPE, > > 0); also make it work in UCRT.So,instead of setlocale(LC_CTYPE, > > ".UTF8"); setlocale(LC_CTYPE, > > 0);` is the temporary solution in both cases.Although I don't why,but I > it > > works anyway,I have test it with GBK,UTF8 and ISO8859-6. > > > > What's the purpose of this patch? > > `setlocale(LC_CTYPE, "")` means to 'set' the locale in an > implementation-defined way. Typically this > means to obtain the current locale from your system, via configuration or > environment variables. > This is necessary because a program starts in the "C" locale. > > `setlocale(LC_CTYPE, 0)` is equivalent to `setlocale(LC_CTYPE, NULL)` and > gets the name of the > current locale, without actually modifying it. In your patch you discard > its result so it does nothing. > > > -- > Best regards, > LIU Hao > > _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
