bug in strcasecmp and strncasecmp
Bruno Haible
bruno@clisp.org
Mon Feb 17 12:04:59 GMT 2025
Corinna Vinschen wrote:
> > They can't work on multibyte strings. This is evident from the fact that
> > strncasecmp gets one integer as argument, not two integers.
>
> Good point.
>
> With standard functions, one really should convert MB string to wide
> char and call wcscasecmp, etc.
Nope, wide characters are the wrong approach to the problem [1].
Nowadays, ISO C 23 has standardized on char32_t as the portable Unicode
character type. [2] They have left the corresponding functions "as an
exercise to the reader", though. Gnulib and GNU libunistring fill this gap.
See the columns "multibyte strings" and "32-bit wide character strings" in [3].
Bruno
[1] https://www.gnu.org/software/gnulib/manual/html_node/The-wchar_005ft-type.html
[2] https://www.gnu.org/software/gnulib/manual/html_node/The-char32_005ft-type.html
[3] https://www.gnu.org/software/gnulib/manual/html_node/Comparison-of-string-APIs.html
More information about the Cygwin
mailing list