Re: [Mingw-w64-public] [patch ]add UTF-8 support for dirname and basename

2023-03-21 Thread 傅继晗
Thanks for the patient explanation. It's my mistake. Now I figure it out that dirname() function works in the "C" locale.and `setlocale(LC_CTYPE, "")` changes the locale to system default. so it causes the transaction. LIU Hao 于2023年3月21日周二 17:39写道: > 在 2023/3/21 17:15, 傅继晗 写道: > > Yes,MSVCRT

Re: [Mingw-w64-public] [patch ]add UTF-8 support for dirname and basename

2023-03-21 Thread 傅继晗
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

Re: [Mingw-w64-public] [patch ]add UTF-8 support for dirname and basename

2023-03-21 Thread LIU Hao
在 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

Re: [Mingw-w64-public] [patch ]add UTF-8 support for dirname and basename

2023-03-21 Thread 傅继晗
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 bo

Re: [Mingw-w64-public] [patch ]add UTF-8 support for dirname and basename

2023-03-20 Thread Alvin Wong via Mingw-w64-public
The thing is, the code point sequence you have here is not valid UTF-8 at all. If it is indeed doing the conversion from UTF-8 you will most likely get incorrect result or crashes. As you realized and reported in another reply that you were actually testing with msvcrt. It is likely that msvcr

Re: [Mingw-w64-public] [patch ]add UTF-8 support for dirname and basename

2023-03-20 Thread 傅继晗
I check it again,found that I actually use MSVCRT instead of UCRT. And so strange that the MSVCRT is working but UCRT failed. 傅继晗 于2023年3月20日周一 19:25写道: > No.I think msvcrt is outdated.So I use ucrt instead. > > LIU Hao 于2023年3月20日周一 19:05写道: > >> 在 2023/3/20 18:52, Alvin Wong via Mingw-w64-pub

Re: [Mingw-w64-public] [patch ]add UTF-8 support for dirname and basename

2023-03-20 Thread LIU Hao
在 2023/3/20 19:25, 傅继晗 写道: No.I think msvcrt is outdated.So I use ucrt instead. There are many distributions that have MSVCRT as the default or only CRT (e.g. Debian). And even with UCRT, I don't think it's valid to blindly assume that the argument is UTF-8 which is not the default. -- Be

Re: [Mingw-w64-public] [patch ]add UTF-8 support for dirname and basename

2023-03-20 Thread 傅继晗
No.I think msvcrt is outdated.So I use ucrt instead. LIU Hao 于2023年3月20日周一 19:05写道: > 在 2023/3/20 18:52, Alvin Wong via Mingw-w64-public 写道: > > Thanks for sending the patches. However my comment on these patches will > be that, they only work > > when the process ANSI codepage (ACP) is UTF-8, w

Re: [Mingw-w64-public] [patch ]add UTF-8 support for dirname and basename

2023-03-20 Thread 傅继晗
However,I use GBK as default code page in my windows , and I try to test it with GBK encoding content .But this trick seems still work.Here is the test case. #include extern char * __cdecl basenam

Re: [Mingw-w64-public] [patch ]add UTF-8 support for dirname and basename

2023-03-20 Thread LIU Hao
在 2023/3/20 18:52, Alvin Wong via Mingw-w64-public 写道: Thanks for sending the patches. However my comment on these patches will be that, they only work when the process ANSI codepage (ACP) is UTF-8, which requires either embedding a manifest with activeCodePage set to UTF-8 or setting the system

Re: [Mingw-w64-public] [patch ]add UTF-8 support for dirname and basename

2023-03-20 Thread Alvin Wong via Mingw-w64-public
Hi, Thanks for sending the patches. However my comment on these patches will be that, they only work when the process ANSI codepage (ACP) is UTF-8, which requires either embedding a manifest with activeCodePage set to UTF-8 or setting the system ACP to UTF-8. If the process is using CP936 (GB

Re: [Mingw-w64-public] [patch ]add UTF-8 support for dirname and basename

2023-03-20 Thread 傅继晗
ok,it has txt extension now Alvin Wong 于2023年3月20日周一 18:10写道: > Hi, if you attached a patch in your mail, it has been stripped by the > mailing list software. Please try renaming it to `.txt` and resend. > > On 20/3/2023 16:55, 傅继晗 wrote: > > Hello maintainers: > > > > According to microsoft pag

Re: [Mingw-w64-public] [patch ]add UTF-8 support for dirname and basename

2023-03-20 Thread Alvin Wong via Mingw-w64-public
Hi, if you attached a patch in your mail, it has been stripped by the mailing list software. Please try renaming it to `.txt` and resend. On 20/3/2023 16:55, 傅继晗 wrote: Hello maintainers: According to microsoft page:setlocale, _wsetlocale | Microsoft Learn

[Mingw-w64-public] [patch ]add UTF-8 support for dirname and basename

2023-03-20 Thread 傅继晗
Hello maintainers: According to microsoft page:setlocale, _wsetlocale | Microsoft Learn *Starting in Windows 10 version 1803 (10.0.17134.0), the Universal C Runtime supports using a UTF-8 code p