From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14629 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: printf doesn't respect locale Date: Mon, 9 Sep 2019 13:54:52 -0400 Message-ID: <20190909175452.GO9017@brightrain.aerifal.cx> References: Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="257249"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-14645-gllmg-musl=m.gmane.org@lists.openwall.com Mon Sep 09 19:55:09 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1i7Nsa-0014iu-Rn for gllmg-musl@m.gmane.org; Mon, 09 Sep 2019 19:55:08 +0200 Original-Received: (qmail 13882 invoked by uid 550); 9 Sep 2019 17:55:05 -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 13861 invoked from network); 9 Sep 2019 17:55:05 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:14629 Archived-At: On Mon, Sep 09, 2019 at 05:31:01PM +0100, Daniel Schoepe wrote: > Hi, > > I think I found a discrepancy between musl's behavior and the POSIX standard: > > According to the POSIX standard, the decimal separator used when using > printf to print floating point numbers should come from the locale > (https://pubs.opengroup.org/onlinepubs/9699919799/functions/fprintf.html): > > "The radix character is defined in the current locale (category > LC_NUMERIC). In the POSIX locale, or in a locale where the radix > character is not defined, the radix character shall default to a > ( '.' )." > > However, it seems that in musl, a period is always used for printing > floating point numbers. For example, the following program prints > "12.0" instead of "12,0" (which is printed when using GNU libc): It's not a discrepancy; the set of locales supported by an implementation, unless it includes the POSIX localedef utility/option, is implementation-defined. musl's definition does not include locales where the radix point is not '.' I really really really don't like the feature of changing the radix point, and this implementation choice was intentional, but it's come up several times with people being upset that it's not in line with musl's mission of being multilingual-friendly. I think it deserves some consideration again along with upcoming locale improvements. There's at least one past thread with design sketches on how it would need to be done (and what needs to be done anyway for LC_MONETARY stuff), and sadly it got no feedback from people interested in improved locale functionality which is why I've kinda let it be for the time being... Rich