strcasecmp/tolower/toupper breakage



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).

George

-- 
George <jirka 5z com>
   People never lie so much as after a hunt, during a war or before an election.
                       -- Otto von Bismarck




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