Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 Sep 1996 06:37:35 +0200 (MET DST)
From:      J Wunsch <j@uriah.heep.sax.de>
To:        freebsd-hackers@freebsd.org (FreeBSD hackers)
Cc:        imp@village.org (Warner Losh)
Subject:   Re: setlocale question
Message-ID:  <199609290437.GAA05650@uriah.heep.sax.de>
In-Reply-To: <199609282135.PAA29387@rover.village.org> from Warner Losh at "Sep 28, 96 03:35:14 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
As Warner Losh wrote:

> 	setlocale(LC_ALL, "");
> 
> I was wondering if that was needed, and if so why?  I thought that
> libc already did the moral equivalent of the semeantics of this before
> passing control to main.  The man page wasn't clear to me why this
> would be needed.

It's not the same.  All programs ought to start in the "C" locale.
The above adjusts all parts of the locale to the current environment's
locale settings, however.  This is a _huge_ difference.

For example, IBM once apparently wrote the above into all of their
programs in AIX, including the C compiler.  The result was that the C
compiler in a German language locale did no longer grok the valid
initialization:

	double pi = 3.1415926;

since the LC_NUMERIC part of the German locale uses a comma instead of
a decimal point. :-O

Yes, cat seems to require a setlocale(), though

	setlocale(LC_CTYPE, "");

is probably sufficient.  It is needed in case the -v option is
specified.

-- 
cheers, J"org

joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199609290437.GAA05650>