[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessing the environment's locale encoding settings

From: Ludovic Courtès
Subject: Re: Accessing the environment's locale encoding settings
Date: Wed, 16 Nov 2011 11:35:39 +0100
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.90 (gnu/linux)

Hi Bruno,

Thanks for your quick and insightful feedback.

Bruno Haible <address@hidden> 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].



> 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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]