This is the mail archive of the
libc-locales@sourceware.org
mailing list for the GNU libc locales project.
Re: Weird case-insensitive collation
- From: "Reshat Sabiq (ReÅat)"<tatar dot iqtelif dot i18n at gmail dot com>
- To: Ludovic CourtÃs <ludovic dot courtes at laas dot fr>
- Cc: libc-locales at sources dot redhat dot com
- Date: Thu, 19 Oct 2006 18:56:02 -0500
- Subject: Re: Weird case-insensitive collation
- Openpgp: id=262839AF;url=http://keyserver.veridis.com:11371
- References: <87k62w1r7f.fsf@laas.fr>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Ludovic CourtÃs yazmÄÅ:
> 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.
>
I think this function is not locale-aware, so it compares characters'
integral value, which naturally produces a positive.
http://opengroup.org/onlinepubs/007908799/xsh/strcasecmp.html
In the POSIX locale, strcasecmp() and strncasecmp() do upper to lower
conversions, then a byte comparison. The results are unspecified in
other locales.
Since is 0xe9, and being an Extended ASCII character greater than both h
(0x68) and H (0x48), this doesn't seem to be a bug to me.
HTH,
Reshat.
- --
My public GPG key (ID 0x262839AF) is at: http://keyserver.veridis.com:11371
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
iD8DBQFFOBCSO75ytyYoOa8RAtvJAJ4hh3k83W6rXdW5OQk1AzbZmybKDwCfWM98
y+onNxS2erMCG+Rc3S+sMmk=
=PuTh
-----END PGP SIGNATURE-----