From unknown Fri Jun 20 07:26:42 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#24990 <24990@debbugs.gnu.org> To: bug#24990 <24990@debbugs.gnu.org> Subject: Status: Wrong formatted output with 'number->locale-string' Reply-To: bug#24990 <24990@debbugs.gnu.org> Date: Fri, 20 Jun 2025 14:26:42 +0000 retitle 24990 Wrong formatted output with 'number->locale-string' reassign 24990 guile submitter 24990 Martin Michel severity 24990 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 22 17:08:23 2016 Received: (at submit) by debbugs.gnu.org; 22 Nov 2016 22:08:23 +0000 Received: from localhost ([127.0.0.1]:38654 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c9JEk-0002ta-LA for submit@debbugs.gnu.org; Tue, 22 Nov 2016 17:08:23 -0500 Received: from eggs.gnu.org ([208.118.235.92]:52742) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c9IvL-0002Lg-Se for submit@debbugs.gnu.org; Tue, 22 Nov 2016 16:48:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9IvF-00081c-O0 for submit@debbugs.gnu.org; Tue, 22 Nov 2016 16:48:14 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,LOTS_OF_MONEY autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:57520) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c9IvF-00081V-L0 for submit@debbugs.gnu.org; Tue, 22 Nov 2016 16:48:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43711) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9IvE-0004ct-At for bug-guile@gnu.org; Tue, 22 Nov 2016 16:48:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9Iv9-0007x8-DE for bug-guile@gnu.org; Tue, 22 Nov 2016 16:48:12 -0500 Received: from euve32322.vserver.de ([85.25.48.132]:48824 helo=famic.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9Iv8-0007wL-TT for bug-guile@gnu.org; Tue, 22 Nov 2016 16:48:07 -0500 Received: from remote.famic.de (ipbcc20513.dynamic.kabel-deutschland.de [188.194.5.19]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by famic.de (Postfix) with ESMTPSA id B35282E0F92 for ; Tue, 22 Nov 2016 22:48:03 +0100 (CET) Date: Tue, 22 Nov 2016 22:48:01 +0100 From: Martin Michel To: bug-guile@gnu.org Subject: Wrong formatted output with 'number->locale-string' Message-ID: <20161122214801.GA20536@remote.famic.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Tue, 22 Nov 2016 17:08:21 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) Hi there, I want to report a bug in the format module using different locales. It seems that 'number->locale-string' and 'monetary-amount->locale-string' are broken. Please see below emails sent to the guile-users mailing list how to reproduce the behaviour. The Guile version I used was 2.0.13. Thanks, -Martin ----- Forwarded message from Vladimir Zhbanov ----- Date: Mon, 14 Nov 2016 09:03:19 +0300 From: Vladimir Zhbanov To: dev@famic.de Subject: Re: Formatted output with locale Hi Martin, On 11/13/16, dev@famic.de wrote: > Hi there, > I have problems to get a proper formatting using the (ice-9 format) > module. In my code, I need to deal with monetary figures, but I fail > to get the correct format for my German locale. > Let's say I have one hundred thousand Euros. The correct format to output > this in de_DE.utf-8 would be > 100.000,00 EUR > (with 2 decimals) > > Now I tried: > (setlocale LC_ALL "de_DE.UTF-8") > (use-modules (ice-9 format)) > (define a 100000.00) > (format #t "~12,2h EUR~%" a) > (format #t "~,,12$ EUR~%" a) > (format #t "~12,2f EUR~%" a) > > But this is what Guile gives to me: > 100.000,0 EUR > 100000.00 EUR > 100000.00 EUR > > None is correct. What did I miss? > -Martin Looking at the `format' code for option `h' I see the procedure `number->locale-string' is used. OK, let's do some experiments: scheme@(guile-user)> (setlocale LC_ALL) $2 = "ru_RU.UTF-8" scheme@(guile-user)> ,use (ice-9 i18n) scheme@(guile-user)> (number->locale-string 10.0 5) $3 = "10,0" scheme@(guile-user)> (number->locale-string .00003 2) $4 = "3,0e" scheme@(guile-user)> (number->locale-string .00003 1) $5 = "3,0" scheme@(guile-user)> (number->locale-string .00003 3) $6 = "3,0e-" scheme@(guile-user)> (number->locale-string .0 3) $7 = "-0,0" scheme@(guile-user)> (number->locale-string .0 10) $8 = "-0,0" scheme@(guile-user)> (number->locale-string .0 1) $9 = "-0,0" Now for the procedure monetary-amount->locale-string: scheme@(guile-user)> (monetary-amount->locale-string .0 #t) $10 = "-0.0 RUB " scheme@(guile-user)> (monetary-amount->locale-string 100000.0 #t) $11 = "100\xa0000.0 RUB " scheme@(guile-user)> (monetary-amount->locale-string .00003 #t) $12 = "3.0e RUB " And my guile version: scheme@(guile-user)> (version) $13 = "2.0.11" It seems `number->locale-string' is broken. If I do, e.g. (number->locale-string .00003 10) it yields "3,0e-5" If the last arg decreases, it just trims the number of characters after comma, which is wrong in this case. Output for zero is funny, too. Regards, Vladimir ----- End forwarded message ----- ----- End forwarded message ----- From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 12 18:24:18 2017 Received: (at 24990-done) by debbugs.gnu.org; 12 Feb 2017 23:24:18 +0000 Received: from localhost ([127.0.0.1]:37533 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cd3VB-0003qn-PZ for submit@debbugs.gnu.org; Sun, 12 Feb 2017 18:24:18 -0500 Received: from eggs.gnu.org ([208.118.235.92]:48383) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cd3VA-0003qa-MW for 24990-done@debbugs.gnu.org; Sun, 12 Feb 2017 18:24:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cd3V4-00055D-DF for 24990-done@debbugs.gnu.org; Sun, 12 Feb 2017 18:24:11 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,LOTS_OF_MONEY, RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:51583) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cd3Uy-000546-6e; Sun, 12 Feb 2017 18:24:04 -0500 Received: from reverse-83.fdn.fr ([80.67.176.83]:55908 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cd3Ux-0005E7-Fp; Sun, 12 Feb 2017 18:24:03 -0500 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) To: Martin Michel Subject: Re: bug#24990: Wrong formatted output with 'number->locale-string' References: <20161122214801.GA20536@remote.famic.de> Date: Mon, 13 Feb 2017 00:24:00 +0100 In-Reply-To: <20161122214801.GA20536@remote.famic.de> (Martin Michel's message of "Tue, 22 Nov 2016 22:48:01 +0100") Message-ID: <87k28vq9gv.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 24990-done Cc: Vladimir Zhbanov , 24990-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) Hi, Martin Michel skribis: > From: Vladimir Zhbanov > Subject: Re: Formatted output with locale > To: dev@famic.de, 24990@debbugs.gnu.org > Date: Mon, 14 Nov 2016 09:03:19 +0300 (12 weeks, 6 days, 15 hours ago) > > Hi Martin, > > On 11/13/16, dev@famic.de wrote: >> Hi there, >> I have problems to get a proper formatting using the (ice-9 format) >> module. In my code, I need to deal with monetary figures, but I fail >> to get the correct format for my German locale. >> Let's say I have one hundred thousand Euros. The correct format to output >> this in de_DE.utf-8 would be >> 100.000,00 EUR >> (with 2 decimals) >> >> Now I tried: >> (setlocale LC_ALL "de_DE.UTF-8") >> (use-modules (ice-9 format)) >> (define a 100000.00) >> (format #t "~12,2h EUR~%" a) >> (format #t "~,,12$ EUR~%" a) >> (format #t "~12,2f EUR~%" a) >> >> But this is what Guile gives to me: >> 100.000,0 EUR >> 100000.00 EUR >> 100000.00 EUR >> >> None is correct. What did I miss? >> -Martin > > Looking at the `format' code for option `h' I see the procedure > `number->locale-string' is used. > > OK, let's do some experiments: > > scheme@(guile-user)> (setlocale LC_ALL) > $2 =3D "ru_RU.UTF-8" > scheme@(guile-user)> ,use (ice-9 i18n) > scheme@(guile-user)> (number->locale-string 10.0 5) > $3 =3D "10,0" > scheme@(guile-user)> (number->locale-string .00003 2) > $4 =3D "3,0e" > scheme@(guile-user)> (number->locale-string .00003 1) > $5 =3D "3,0" > scheme@(guile-user)> (number->locale-string .00003 3) > $6 =3D "3,0e-" > scheme@(guile-user)> (number->locale-string .0 3) > $7 =3D "-0,0" > scheme@(guile-user)> (number->locale-string .0 10) > $8 =3D "-0,0" > scheme@(guile-user)> (number->locale-string .0 1) > $9 =3D "-0,0" > > Now for the procedure monetary-amount->locale-string: > > scheme@(guile-user)> (monetary-amount->locale-string .0 #t) > $10 =3D "-0.0 RUB " > scheme@(guile-user)> (monetary-amount->locale-string 100000.0 #t) > $11 =3D "100\xa0000.0 RUB " > scheme@(guile-user)> (monetary-amount->locale-string .00003 #t) > $12 =3D "3.0e RUB " I believe these are fixed by commit 4aead68cdb86ca60cc372f0cd558cadda90ddec5. You=E2=80=99re welcome to do more testing and report back! Thanks, Ludo=E2=80=99. From unknown Fri Jun 20 07:26:42 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 13 Mar 2017 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator