bug in strcasecmp and strncasecmp
Bruno Haible
bruno@clisp.org
Mon Feb 17 10:49:50 GMT 2025
Corinna Vinschen wrote:
> Adding a cast fixes that and I just pushed a matching patch.
Thanks.
> I'm just not sure if that's sufficient in the light of POSIX.1-2024.
> The above expression seems to indicate that strcasecmp and friends are
> now expected to work on multibyte codesets like UTF-8.
They can't work on multibyte strings. This is evident from the fact that
strncasecmp gets one integer as argument, not two integers. In a Turkish
locale, for example, "i" (1 byte) and "İ" (2 bytes) are the same modulo
case.
I agree that the POSIX language is murky because "character" there is
equivalent to "byte", and yet the same page talks about characters and bytes...
For multibyte strings, one needs other functions. See
https://www.gnu.org/software/gnulib/manual/html_node/Comparison-of-string-APIs.html
Bruno
More information about the Cygwin
mailing list