From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bruno Haible Newsgroups: gmane.lisp.guile.devel Subject: Re: Accessing the environment's locale encoding settings Date: Sun, 20 Nov 2011 17:55:18 +0100 Message-ID: <201111201755.18910.bruno@clisp.org> References: <877h30exfk.fsf@gnu.org> <201111160300.38410.bruno@clisp.org> <87r5189wxw.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1321808144 26579 80.91.229.12 (20 Nov 2011 16:55:44 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 20 Nov 2011 16:55:44 +0000 (UTC) Cc: guile-devel@gnu.org To: Ludovic =?utf-8?q?Court=C3=A8s?= Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Nov 20 17:55:39 2011 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RSAg7-0003sW-LQ for guile-devel@m.gmane.org; Sun, 20 Nov 2011 17:55:39 +0100 Original-Received: from localhost ([::1]:33048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RSAg7-0005ul-70 for guile-devel@m.gmane.org; Sun, 20 Nov 2011 11:55:39 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:57549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RSAg4-0005ub-Ah for guile-devel@gnu.org; Sun, 20 Nov 2011 11:55:37 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RSAg3-0008JT-Dr for guile-devel@gnu.org; Sun, 20 Nov 2011 11:55:36 -0500 Original-Received: from mo-p00-ob.rzone.de ([81.169.146.160]:10184) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RSAg1-0008JF-8N; Sun, 20 Nov 2011 11:55:33 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1321808131; l=2382; s=domk; d=haible.de; h=Content-Transfer-Encoding:Content-Type:MIME-Version:In-Reply-To: References:Cc:Date:Subject:To:From:X-RZG-CLASS-ID:X-RZG-AUTH; bh=MN8Bbom42Iism+WRc30XtU+Z7wk=; b=ihNYmEyxIryFxJv9RCDEDr7U4aqMlIAZ5ZAQYaCy3E98GCwhJtjiv93EOTk9j/93nze JOmiDJ1l948fblWI0E3E18WoXP/PwmqdkkTYx55u5knA9SXPNppznausT4Gq26dAXYCni RwBg2VWNcmrVagWw8n6coXB4x1zX9TaNsbE= X-RZG-AUTH: :Ln4Re0+Ic/6oZXR1YgKryK8brksyK8dozXDwHXjf9hj/zDNRb/444HDCpg== X-RZG-CLASS-ID: mo00 Original-Received: from linuix.haible.de (dslb-088-068-068-248.pools.arcor-ip.net [88.68.68.248]) by smtp.strato.de (jimi mo5) (RZmta 26.10 AUTH) with ESMTPA id Y051c1nAKGYTFp ; Sun, 20 Nov 2011 17:55:20 +0100 (MET) User-Agent: KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; ) In-Reply-To: <87r5189wxw.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 81.169.146.160 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:12913 Archived-At: Ludovic Courtès wrote: > It seems to me that the implicit call is often desirable, but at the > same time, it imposes a policy on the application. In C, Guile, & co., > the application can choose to ignore the locale, or to just honor > LC_CTYPE, or to set something different. What it actually does, then, is that it uses a mix of the user-provided locale (for some locale categories) and the "C" locale (for some other locale categories. When the default category is the user-provided one, rather than "C", it is still possible, it just needs different code to do so. Instead of (setlocale LC_CTYPE "") the user will now need to write (setlocale LC_NUMERIC "C") (setlocale LC_MONETARY "C") (setlocale LC_COLLATE "C") (setlocale LC_MESSAGES "C") (setlocale LC_TIME "C") > > So my suggestion is to do (setlocale LC_ALL "") as part of the Guile > > initialization, very early. Yes, this might lead to some complexity > > in the Guile implementation if you have the concept of locale also at > > the Guile level and need to make sure that the locale at the C level and > > the locale at the Guile level are consistent as soon as the latter is > > defined. But this is manageable. > > Are you suggesting that we could arrange to have Guile’s ‘main’ call > setlocale(LC_ALL, "") while still giving Scheme code the impression that > it’s started under the C locale as is currently the case? No, I'm suggesting to let the Scheme code know that is it using the user's locale. Yes, this is a backward-incompatible change, so probably you won't want to do it on the guile 2.0.x branch, and you will want to advertise it in the release notes or NEWS file. > A reasonable option would be to setlocale(LC_CTYPE, "") from Guile’s > ‘main’, so that scm_from_locale_string & co. would DTRT. But again that > would change the value of %default-port-encoding, leading to potential > application breakage. In the long run, this would be more complex: users who see that LC_CTYPE from the environment is respected would also expect that LC_COLLATE etc. from the environment is respected. I would just do the change and make it clear that old applications that really want to stay in the C locale should call (setlocale LC_ALL "C") Bruno -- In memoriam Kerem Yılmazer