Date: Thu, 24 May 2007 14:24:32 +0400 From: "Artem Kuchin" <matrix@itlegion.ru> To: <freebsd-stable@freebsd.org> Subject: How to test locale in C? All my tests fail. Message-ID: <023401c79ded$ba3b7fe0$05000100@Artem>
next in thread | raw e-mail | index | archive | help
Maybe it is the wrong list, but maybe someone can quickly
help me out.
I have a very stupid problem. I cannot convert to upper
or lower case using manually set locale (setlocale(..)).
A very simple program:
#include <locale.h>
#include <errno.h>
#include <ctype.h>
main(){
char *b=setlocale(LC_CTYPE, "ru_RU.CP1251");
if (!b){
printf("FAILED! %d\n",errno);
}
else {
printf("OK: %s %d\n",b,errno);
printf("IS UPPER Ê: %d\n",isupper('Ê'));
printf("IS UPPER ê: %d\n",isupper('ê'));
printf("IS LOWER Ê: %d\n",islower('Ê'));
printf("IS LOWER ê: %d\n",islower('ê'));
printf("LOCALE %s\n",setlocale(LC_CTYPE,NULL));
printf("1: TO UPPER %c TO LOWER %c\n",toupper('Ö'),tolower('ö'));
printf("1-0: TO UPPER %c TO LOWER %c\n",toupper('ñ'),tolower('Ñ'));
printf("2: TO UPPER %c TO LOWER %c\n",toupper('r'),tolower('R'));
}
}
Output is always:
OK: ru_RU.CP1251 0
IS UPPER Ê: 0
IS UPPER ê: 0
IS LOWER Ê: 0
IS LOWER ê: 0
LOCALE ru_RU.CP1251
1: TO UPPER Ö TO LOWER ö
1-0: TO UPPER ñ TO LOWER Ñ
2: TO UPPER R TO LOWER r
Ê,Ö,Ñ - is lower case leters and
ê,ö,ñ - is upper case
As you see, it simply does not work at all.
It seems like the locale is "C" but as you see
setlocale returned ru_RU.CP1251
tested on 6.2, 5.4 and 4.10 - all the same.
What am i doing wrong?
(except posting in the wrong list ;)
--
Regards,
Artem
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?023401c79ded$ba3b7fe0$05000100>
