Re: [Mingw-w64-public] [PATCH] rewrite the dirname.c and basename.c without wide character processing

2023-03-25 Thread
orming multi-byte chars have the MSB set, > unlike some DBCS). > > > On 23/3/2023 13:29, LIU Hao wrote: > > 在 2023-03-22 13:40, 傅继晗 写道: > >> Hello: > >> There is no need to convert multi-byte characters to wide-byte > >> characters and then convert from

Re: [Mingw-w64-public] [PATCH] Fix trunsaction Bug in dirname.c and filename.c

2023-03-23 Thread
Sorry,Since starting in Windows 10 version 1803 (10.0.17134.0), the Universal C Runtime supports using a UTF-8 code page. Two bytes for every wide character may not be enough,best to use wcstombs (NULL, wcstr, 0) to get the size correctly.here is the patch. 傅继晗 于2023年3月23日周四 16:21写道: > I

[Mingw-w64-public] [PATCH] Fix trunsaction Bug in dirname.c and filename.c

2023-03-23 Thread
I was going to refactor these two functions, but after LIU Hao's explanation, I realized that I just took it too easy, and more thought should be given to windows than linux, so I gave up on refactoring and just fixed its bugs. Even if the locale was consistent with the input filename, it would

Re: [Mingw-w64-public] [PATCH] rewrite the dirname.c and basename.c without wide character processing

2023-03-22 Thread
Thanks for your attention! I really understand this time.But I still have a question,why dirname in linux glib doesn't process MBCS? Maybe they think input as UTF-8 as default? LIU Hao 于2023年3月23日周四 13:30写道: > 在 2023-03-22 13:40, 傅继晗 写道: > > Hello: > > There is no need t

[Mingw-w64-public] [PATCH] rewrite the dirname.c and basename.c without wide character processing

2023-03-21 Thread
Hello: There is no need to convert multi-byte characters to wide-byte characters and then convert from wide-byte to multi-byte, just deal with multi-byte directly as __xpg_basename in gnu as this: glibc/xpg_basename.c at master · lattera/glibc (github.com)

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 1

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

2023-03-21 Thread
tested it many times and didn't find anything related in the Microsoft documents. LIU Hao 于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");

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

2023-03-21 Thread
rom 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 msvcrt just ignored the unsupported > locale and was doing something unspecified. > On 20/3/2023 19:07, 傅继晗 wr

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

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
not thread-safe), then replace > `mbstowcs` and `wcstombs` with direct usage of `MultiByteToWideChar` and > `WideCharToMultiByte`, which can convert from/to CP_ACP directly. > > Best Regards, > Alvin > On 20/3/2023 18:36, 傅继晗 wrote: > > ok,it has txt extension now >

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: > > &g

[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