I think glibc just did not implement this behavior yet. There have been nearly zero real changes to its `btowc` since like 2007.
https://sourceware.org/git/?p=glibc.git;a=history;f=wcsmbs/btowc.c;h=7be040ff6688d31da585d9075bdee54d231550d1;hb=refs/heads/master I think it should be ok for replacement's behavior to match CRT. Note: manpage link you attached is for `POSIX Programmer's Manual`, not C Library (Library Functions Manual). - Kirill Makurin ________________________________ From: LIU Hao Sent: Tuesday, June 3, 2025 8:19 PM To: Kirill Makurin; mingw-w64-public@lists.sourceforge.net Subject: Re: [Mingw-w64-public] Inconsistent behavior of btowc with "C" locale 在 2025-6-3 19:11, Kirill Makurin 写道: > Oh, my bad. I was thinking I was calling MSVCRT's `btowc`, not the > replacement. > > I tried calling real `btowc` and its behavior matches UCRT. I also tried > loading msvcr100.dll, it has the > same behavior. > > So, I think we could check return value of `___lc_codepage_func()` and for > "C" locale, return values in > range [0,255] as is and return WEOF if value is outside this range. > > Should we change behavior so that replacement is used only when there is no > real `btowc`? I do not fully > understand how this mechanism works. > > Btw, glibc's `btowc` returns WEOF for characters in range [128,255] with "C" > locale. The behavior of > btowc not returning WEOF for values in range [128,255] seems to be new. > Existing manpages do not mention it. > This? https://man7.org/linux/man-pages/man3/btowc.3p.html#RETURN_VALUE If you can find the rationale about the glibc change, I think it's fine to adopt the POSIX behavior. -- Best regards, LIU Hao _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public