From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Vladimir Zhbanov Newsgroups: gmane.lisp.guile.user Subject: Re: Formatted output with locale Date: Thu, 17 Nov 2016 19:53:25 +0300 Message-ID: <20161117165324.GA17273@localhost.localdomain> References: <20161113165638.GA23086@remote.famic.de> <87inrm5pzl.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1479401640 29020 195.159.176.226 (17 Nov 2016 16:54:00 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 17 Nov 2016 16:54:00 +0000 (UTC) User-Agent: Mutt/1.5.23 (2014-03-12) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Nov 17 17:53:53 2016 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c7Pwe-0006Hg-Oq for guile-user@m.gmane.org; Thu, 17 Nov 2016 17:53:52 +0100 Original-Received: from localhost ([::1]:60257 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c7Pwh-0007L3-NE for guile-user@m.gmane.org; Thu, 17 Nov 2016 11:53:55 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50750) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c7PwM-0007Km-95 for guile-user@gnu.org; Thu, 17 Nov 2016 11:53:35 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c7PwH-0001Hu-Dr for guile-user@gnu.org; Thu, 17 Nov 2016 11:53:34 -0500 Original-Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]:37537) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c7PwH-0001Hb-5a for guile-user@gnu.org; Thu, 17 Nov 2016 11:53:29 -0500 Original-Received: by mail-wm0-x234.google.com with SMTP id t79so157294034wmt.0 for ; Thu, 17 Nov 2016 08:53:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=LdeSApa8XezEFrGCUuj4ryTv8o9Ya8QL9OswDp0YhVA=; b=pmPDee2adWsL4wPjQDghjXRok01JlboSRv6t3E5t+Q+dchfsAM2/1RaIAG5I2gEyFO 9V3kzPiQdwbi0Xyt9Mqv9vpFuuAJKklEUX5S56ujMfXHwJA++BqGQiulvhF1x3PRlfJb miZWaP0uUknmbsBbTBaTeJLcbnvas+yVMVzyAtn2Z1SunV/9ipnu6c6vKM9BOi/3BcHf DNczYclX1NiDYNJZumjxzYUOuGyugYwoNTpENsc9XgVTYCbbLFFa7pJLUbivZ6wdX8le 40ezymEM4OESye1ANgTHOwk15lr+0dTFY9ceQwvSkpqazWEpxgrEFKmTpWskbVDqEnZ7 glwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=LdeSApa8XezEFrGCUuj4ryTv8o9Ya8QL9OswDp0YhVA=; b=c087R7Qm/+WZEpoiaOxM3lId+s4lW9M7aBl/39wdNvAy/qc2l7b0MryuDWO9MqXAy7 kAkDvnEO6qMD1mZ2bRoSeMRLeVDOQPTXVxtw9snk1CXTPn3ERcFyVJNtaREiN3st9Tqw 6MnYxfc0dvUWOpIHR3Mg6Cz9Is66LE+tRCSajKlMZikXsnxZOyLeLBIZlK3dAGI08Z+k qqp4nj7H1EJQbuGARnB1vxXeztbUAL0EBkVW1lLaPlI9sryfnKUy4VX1jsdjcksRwMz3 2Bp0LvnLqeASCR10pvgplvOeuTwChevUHilSJLVFlNZUADeP7b+R9SJglmclS9+qWH2p mn5g== X-Gm-Message-State: ABUngvfHweg1DEQnliqEfQ6FouiIIaNOdTi45vvmUIvhrk8fn9dsLBXjHQxI/1wfwLLdYQ== X-Received: by 10.25.210.213 with SMTP id j204mr760907lfg.65.1479401606651; Thu, 17 Nov 2016 08:53:26 -0800 (PST) Original-Received: from newvzh.vzh ([213.24.125.150]) by smtp.gmail.com with ESMTPSA id e94sm989638lji.40.2016.11.17.08.53.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Nov 2016 08:53:26 -0800 (PST) Original-Received: from vovka by newvzh.vzh with local (Exim 4.84_2) (envelope-from ) id 1c7PwD-00030V-3h for guile-user@gnu.org; Thu, 17 Nov 2016 19:53:25 +0300 Mail-Followup-To: guile-user@gnu.org Content-Disposition: inline In-Reply-To: <87inrm5pzl.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::234 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:12992 Archived-At: On Thu, Nov 17, 2016 at 12:02:06PM +0100, Ludovic Courtès wrote: > Hi! > > dev@famic.de skribis: > > > 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 > > It seems to work as advertised for me: > > --8<---------------cut here---------------start------------->8--- > scheme@(guile-user)> ,use(ice-9 i18n) > scheme@(guile-user)> (number->locale-string 10000.01 2 (make-locale LC_ALL "fr_FR.utf8")) > $13 = "10 000,01" > scheme@(guile-user)> (number->locale-string 10000.01 2 (make-locale LC_ALL "de_DE.utf8")) > $14 = "10.000,01" > scheme@(guile-user)> ,use(ice-9 format) > scheme@(guile-user)> (setlocale LC_ALL "de_DE.utf8") > $15 = "de_DE.utf8" > scheme@(guile-user)> (format #f "~12,2h" 10000.01) > $16 = " 10.000,01" > --8<---------------cut here---------------end--------------->8--- What does it output if you type (number->locale-string 10000.00 2 (make-locale LC_ALL "fr_FR.utf8")) that is with two zeros after the point? I would expect the same two zeros if the second argument is 2... Am I wrong? > That’s on GNU/Linux (glibc 2.24). > > Note that number formatting data comes from the C library. What C > library do you use? My glibc version is 2.19. Thanks -- Vladimir