From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10080 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: How to set UTF-8 as default Date: Thu, 2 Jun 2016 13:32:58 -0400 Message-ID: <20160602173258.GL10893@brightrain.aerifal.cx> References: <20160602150154.GJ10893@brightrain.aerifal.cx> <20160602171001.GA10492@voyager> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1464888800 10060 80.91.229.3 (2 Jun 2016 17:33:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 2 Jun 2016 17:33:20 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-10093-gllmg-musl=m.gmane.org@lists.openwall.com Thu Jun 02 19:33:15 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1b8WUc-0002xf-NS for gllmg-musl@m.gmane.org; Thu, 02 Jun 2016 19:33:15 +0200 Original-Received: (qmail 32625 invoked by uid 550); 2 Jun 2016 17:33:12 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 32601 invoked from network); 2 Jun 2016 17:33:11 -0000 Content-Disposition: inline In-Reply-To: <20160602171001.GA10492@voyager> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:10080 Archived-At: On Thu, Jun 02, 2016 at 07:10:01PM +0200, Markus Wichmann wrote: > On Thu, Jun 02, 2016 at 05:40:54PM +0200, Remko Tronçon wrote: > > So, if I understand correctly, any program that expects `nl_langinfo` > > to return the locale set through environment variables (or other > > platform-specific ways) should call setlocale(LC_*, "") before > > querying the locale; libc/musl/... will not trigger this registration > > itself. > > A libc that did that wouldn't be ISO-C compliant, because ISO-C says > that the initial locale has to be "C". Well per ISO C, it could define the C locale that way (like musl used to) but it's subject to some restrictions that musl did not follow, making it slightly non-conforming. POSIX however is going to require a byte-based C locale, and already has further requirements on character classes that made it hard to conform to without just adopting the future requirement. > I will often just call setlocale(LC_ALL, ""); at the start of the > program, as that saves me the headache of selecting all the correct > locale categories for my program. Yes, this is a good practice, although often you want to avoid setting LC_NUMERIC or explicitly set it back to "C" so that floating point number parsing/printing is not broken. Rich