From owner-freebsd-stable@FreeBSD.ORG Thu May 24 10:24:40 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 26C1616A46C for ; Thu, 24 May 2007 10:24:40 +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 13D9213C4AD for ; Thu, 24 May 2007 10:24:38 +0000 (UTC) (envelope-from matrix@itlegion.ru) Received: (qmail 14467 invoked from network); 24 May 2007 14:24:37 +0400 Received: from unknown (HELO Artem) (192.168.0.12) by 84.21.226.211 with SMTP; 24 May 2007 14:24:37 +0400 X-AntiVirus: Checked by Dr.Web [version: 4.33, engine: 4.33.5.10110, virus records: 203259, updated: 24.05.2007] Message-ID: <023401c79ded$ba3b7fe0$05000100@Artem> From: "Artem Kuchin" To: Date: Thu, 24 May 2007 14:24:32 +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 Subject: 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 10:24:40 -0000 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