This is the mail archive of the
libc-locales@sourceware.org
mailing list for the GNU libc locales project.
Weird case-insensitive collation
- From: ludovic dot courtes at laas dot fr (Ludovic Courtès)
- To: libc-locales at sources dot redhat dot com
- Date: Thu, 19 Oct 2006 13:27:00 +0200
- Subject: Weird case-insensitive collation
- Organization: LAAS-CNRS
Hi,
`strcasecmp ()' behaves wrongly under the `fr_FR' locale. Consider the
following example program:
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
#include <strings.h>
int
main (int argc, char *argv[])
{
int result;
if (!setlocale (LC_ALL, "fr_FR.ISO-8859-1"))
abort ();
result = strcasecmp ("été", "Hiver");
printf ("result=%i\n", result);
return (result < 0) ? 0 : 1;
}
Under French collation conventions, letter `é' (`e' with acute) comes
before `h'. Thus, the word "été" should be "lower than" the word
"hiver". `strcoll ()' returns the right answer (a negative number) but
`strcasecmp ()' wrongfully returns a positive number, regardless of
whether "hiver" is spelt with a capital `H' or not.
Is this a bug or am I missing something?
Thanks,
Ludovic.