From owner-freebsd-stable@FreeBSD.ORG Sat Aug 12 17:24:38 2006 Return-Path: X-Original-To: freebsd-stable@freebsd.org Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 498D616A4DA; Sat, 12 Aug 2006 17:24:38 +0000 (UTC) (envelope-from marck@rinet.ru) Received: from woozle.rinet.ru (woozle.rinet.ru [195.54.192.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id A570E43D46; Sat, 12 Aug 2006 17:24:37 +0000 (GMT) (envelope-from marck@rinet.ru) Received: from localhost (localhost [127.0.0.1]) by woozle.rinet.ru (8.13.6/8.13.6) with ESMTP id k7CHOaRV029102; Sat, 12 Aug 2006 21:24:36 +0400 (MSD) (envelope-from marck@rinet.ru) Date: Sat, 12 Aug 2006 21:24:36 +0400 (MSD) From: Dmitry Morozovsky To: "Andrey V. Elsukov" In-Reply-To: <44DE08B4.000003.11633@soapbox.yandex.ru> Message-ID: <20060812212327.Q25511@woozle.rinet.ru> References: <44DDDCC5.000001.21350@pantene.yandex.ru> <20060812155431.GG25753@deviant.kiev.zoral.com.ua> <44DE08B4.000003.11633@soapbox.yandex.ru> X-NCC-RegID: ru.rinet X-OpenPGP-Key-ID: 6B691B03 MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0.2 (woozle.rinet.ru [0.0.0.0]); Sat, 12 Aug 2006 21:24:36 +0400 (MSD) Cc: kostikbel@gmail.com, maxim@freebsd.org, freebsd-stable@freebsd.org Subject: Re: setlocale howto 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: Sat, 12 Aug 2006 17:24:38 -0000 On Sat, 12 Aug 2006, Andrey V. Elsukov wrote: AVE> >On Sat, Aug 12, 2006 at 05:51:01PM +0400, Andrey V. Elsukov wrote: AVE> >> for(i = 0; i < sizeof(buf); i++) AVE> >> buf[i] = (char)toupper(buf[i]); AVE> > AVE> > buf[i] = (char)toupper((unsigned char)buf[i]); AVE> >Standard integer promotion promotes KOI8-R char codes like 0xd4 into 0xffffffd4. AVE> >Since such codepoints are not defined for KOI8-R, toupper returns them AVE> >unchaged, as specified in documentation. AVE> AVE> Thanks, this works! But why this example works on Linux without type conversions? Linux has unsigned chars by default, while FreeBSD (and other current *BSDs) signed. Even large projects like PostgreSQL stepped into this trap at least once ;-) Sincerely, D.Marck [DM5020, MCK-RIPE, DM3-RIPN] ------------------------------------------------------------------------ *** Dmitry Morozovsky --- D.Marck --- Wild Woozle --- marck@rinet.ru *** ------------------------------------------------------------------------