From owner-freebsd-stable@FreeBSD.ORG Thu May 24 11:33:56 2007 Return-Path: X-Original-To: freebsd-stable@freebsd.org Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8FF8A16A46D for ; Thu, 24 May 2007 11:33:56 +0000 (UTC) (envelope-from matrix@itlegion.ru) Received: from corpmail.itlegion.ru (corpmail.itlegion.ru [84.21.226.211]) by mx1.freebsd.org (Postfix) with SMTP id CFFA413C48C for ; Thu, 24 May 2007 11:33:55 +0000 (UTC) (envelope-from matrix@itlegion.ru) Received: (qmail 17417 invoked from network); 24 May 2007 15:33:53 +0400 Received: from unknown (HELO Artem) (192.168.0.12) by 84.21.226.211 with SMTP; 24 May 2007 15:33:53 +0400 X-AntiVirus: Checked by Dr.Web [version: 4.33, engine: 4.33.5.10110, virus records: 203259, updated: 24.05.2007] Message-ID: <02e401c79df7$676b80d0$05000100@Artem> From: "Artem Kuchin" To: "Massimo Fusaro" References: <023401c79ded$ba3b7fe0$05000100@Artem> <60f6f5610705240347g708c3375i82d176e415e80b4@mail.gmail.com> Date: Thu, 24 May 2007 15:33:49 +0400 Organization: IT Legion MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="koi8-r"; reply-type=original Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.3028 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 Cc: freebsd-stable@freebsd.org Subject: Re: How to test locale in C? All my tests fail. X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 May 2007 11:33:56 -0000 Massimo Fusaro wrote: >> From the setlocale(3) manual page: >> >> ... A locale argument of NULL causes setlocale() to return the >> current locale. ... Right. that why i first call setlocale(LC_CTYPE, "ru_RU.CP1251"); to set locale and the call setlocale(LC_CTYPE,NULL); to check what locale is currently set. I tried without call setlocale(LC_CTYPE,NULL); - no difference. -- Regards, Artem >> -- >> -max >> >> 2007/5/24, Artem Kuchin : >>> 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 >>> #include >>> #include >>> >>> 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" >>> >> > > > >> _______________________________________________ >> 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"