unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Noah Lavine <noah.b.lavine@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: Bruno Haible <bruno@clisp.org>, guile-devel@gnu.org
Subject: Re: Accessing the environment's locale encoding settings
Date: Wed, 16 Nov 2011 08:11:15 -0800	[thread overview]
Message-ID: <CA+U71=Py2yLi5FB1bhPPHw5bFkpUpTCbosLKGefTnSKy4Wds6g@mail.gmail.com> (raw)
In-Reply-To: <87r5189wxw.fsf@gnu.org>

Hello,

It seems like the right thing to do might be to do setlocale(LC_ALL,
"") in Guile's main(). Let me argue that this accomplishes two goals
which we want to accomplish
  - it does the right thing by default: you want your program to be
able to talk to the user in the user's own language. This accomplishes
that, and also fixes the bug that has been discussed.
  - it lets the user customize Guile's behavior: the user has two
options for going back to the old behavior. First of all, they can do
setlocale(LC_ALL, "C") as soon as their program starts to get back the
default behavior. Second, if they really don't want any locale
changes, they can provide their own main function. We might even be
able to offer a configuration option, so that they could use Guile's
main except for the setlocale call.

However, it seems like in this case, setlocale(LC_ALL, "") is the
right thing in almost every case, and it should just be Guile's
default.

Noah

On Wed, Nov 16, 2011 at 2:35 AM, Ludovic Courtès <ludo@gnu.org> wrote:
> Hi Bruno,
>
> Thanks for your quick and insightful feedback.
>
> Bruno Haible <bruno@clisp.org> skribis:
>
>> That is precisely the point. Only in C, C++, Objective C, PHP, and Guile,
>> it is the user's responsibility to set the locale. Look at the many
>> internationalization samples ("hello world" samples) in GNU gettext:
>> In all other languages (and even many GUI toolkits based on C, C++, or
>> Objective C) the setlocale call is implicit.
>
> 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.  Perhaps this point is moot if
> the other languages allow the locale to be set afterward without any
> loss of functionality, though...
>
>> The user should *not* have to worry about conversion of strings from/to
>> locale encoding, because
>>   1) This is what people expect from a scripting language nowadays.
>>   2) In Guile strings are sequences of Unicode characters [1][2].
>
> Agreed.
>
> [...]
>
>> 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?
>
> Just adding setlocale(LC_ALL, "") in Guile’s ‘main’ would be an
> incompatible change, which would break Scheme applications relying on
> the current behavior–e.g., applications intended to be all-English.
>
> 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.
>
> Thanks,
> Ludo’.
>
>



  reply	other threads:[~2011-11-16 16:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-16  0:13 Accessing the environment's locale encoding settings Ludovic Courtès
2011-11-16  2:00 ` Bruno Haible
2011-11-16 10:35   ` Ludovic Courtès
2011-11-16 16:11     ` Noah Lavine [this message]
2011-11-16 16:32       ` Peter Brett
2011-11-18 22:17         ` Mark H Weaver
2011-11-20 16:55     ` Bruno Haible
2011-11-20 17:41       ` Ludovic Courtès
2011-11-20 19:44         ` Mike Gran
2011-11-23 23:28           ` Ludovic Courtès
2011-11-24  4:42             ` Mike Gran
2011-11-24 13:16             ` Peter Brett
2011-11-25  2:11             ` Mark H Weaver
2011-12-15 19:08               ` Ludovic Courtès
2011-11-20 20:12         ` Bruno Haible
2011-12-15  0:41           ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+U71=Py2yLi5FB1bhPPHw5bFkpUpTCbosLKGefTnSKy4Wds6g@mail.gmail.com' \
    --to=noah.b.lavine@gmail.com \
    --cc=bruno@clisp.org \
    --cc=guile-devel@gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).