Date: Thu, 24 May 2007 12:47:03 +0200 From: "Massimo Fusaro" <mcfusaro@gmail.com> To: "Artem Kuchin" <matrix@itlegion.ru> Cc: freebsd-stable@freebsd.org Subject: Re: How to test locale in C? All my tests fail. Message-ID: <60f6f5610705240347g708c3375i82d176e415e80b4@mail.gmail.com> In-Reply-To: <023401c79ded$ba3b7fe0$05000100@Artem> References: <023401c79ded$ba3b7fe0$05000100@Artem>
next in thread | previous in thread | raw e-mail | index | archive | help
From the setlocale(3) manual page:
... A locale argument of NULL causes setlocale() to return the
current locale. ...
--
-max
2007/5/24, Artem Kuchin <matrix@itlegion.ru>:
> 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
>
> _______________________________________________
> freebsd-stable@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-stable
> To unsubscribe, send any mail to "freebsd-stable-unsubscribe@freebsd.org"
>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?60f6f5610705240347g708c3375i82d176e415e80b4>
