Re: strcasecmp/tolower/toupper breakage



On 03 May 2001 19:51:22 -0700, George wrote:
> GNOME (and about 99% of software out there apparently) is broken with respect
> to working in some locales like say turkish.  Wanna see something fun?
> Try running the following:
> 
> #include <ctype.h>
> #include <stdio.h>
> #include <locale.h>
> int main (void)
> {
>       setlocale (LC_ALL, "tr_TR");
>       printf ("tolower('I')='%c' 'i'='%c' (tolower('I') == 'i')=%d\n",
>               tolower('I'), 'i',
>               tolower('I') == 'i');
>       printf ("strcasecmp (\"BIG\", \"big\") = %d\n",
>               strcasecmp ("BIG", "big"));
>       return 0;
> }
> 
> It will not be what you expect.  We need ascii only versions of these things.
> In fact if you are using g_strcasecmp for something that requires locale info
> you should be using strcoll anyway.
> 
> I have made _no_locale version of strcasecmp in pong/grapevine/panel etc, but
> wasn't aware of any actual locale where it was broken, plus until today I
> sort of forgot this problem existed.  Anyway the affected functions are:
> isupper, islower, toupper, tolower, strcasecmp, strncasecmp.
> 
> I suggest we get ascii only versions into glib 2.  In fact I suggest
> g_strcasecmp and g_strncasecmp work as ascii only, since there doesn't seem
> to be any legitimite reason for use of a locale specific strcasecmp (again,
> strcoll should be used).

What is the use of these functions?  If we're doing comparisons of
strings in a case-insensitive way, shouldn't we always use a utf8
strcoll?  What use is it other than that?

Thanks,
    Chris





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]