unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#22902: GUILE_INSTALL_LOCALE not equivalent to setlocale
@ 2016-03-04  3:34 Zefram
  2016-06-20 16:16 ` Andy Wingo
  2016-08-07 21:53 ` Andy Wingo
  0 siblings, 2 replies; 3+ messages in thread
From: Zefram @ 2016-03-04  3:34 UTC (permalink / raw)
  To: 22902

The documentation claims that setting GUILE_INSTALL_LOCALE=1 in the
environment is equivalent to calling (setlocale LC_ALL "") at startup.
Actually there is at least one difference: calling setlocale causes ports
(both primordial and later-opened) to be initially configured for the
locale's nominal character encoding, but setting the environment variable
does not.  Setting the environment variable leaves the port encoding at
#f, functioning as ISO-8859-1, just as if locale had not been invoked
at all.  I do see some effects from setting the environment variable,
specifically message strings affecting strftime.

$ echo -n $'L\xc3\xa9on' | LANG=de_DE.UTF-8 guile-2.0 -c '(write (strftime "%c" (gmtime 1000000000))) (newline) (write (port-encoding (current-input-port))) (newline) (write (map char->integer (let r ((l '\''())) (let ((c (read-char (current-input-port)))) (if (eof-object? c) (reverse l) (r (cons c l))))))) (newline)'
"Sun Sep  9 01:46:40 2001"
#f
(76 195 169 111 110)
$ echo -n $'L\xc3\xa9on' | GUILE_INSTALL_LOCALE=1 LANG=de_DE.UTF-8 guile-2.0 -c '(write (strftime "%c" (gmtime 1000000000))) (newline) (write (port-encoding (current-input-port))) (newline) (write (map char->integer (let r ((l '\''())) (let ((c (read-char (current-input-port)))) (if (eof-object? c) (reverse l) (r (cons c l))))))) (newline)'
"So 09 Sep 2001 01:46:40 GMT"
#f
(76 195 169 111 110)
$ echo -n $'L\xc3\xa9on' | LANG=de_DE.UTF-8 guile-2.0 -c '(setlocale LC_ALL "") (write (strftime "%c" (gmtime 1000000000))) (newline) (write (port-encoding (current-input-port))) (newline) (write (map char->integer (let r ((l '\''())) (let ((c (read-char (current-input-port)))) (if (eof-object? c) (reverse l) (r (cons c l))))))) (newline)'
"So 09 Sep 2001 01:46:40 GMT"
"UTF-8"
(76 233 111 110)

In case anyone trawls the archives later investigating the usage of
GUILE_INSTALL_LOCALE: I am not attempting to use it myself, despite the
scenario implied by the above test cases.  I think it's a bloody stupid
mechanism, imposing on the program something that needs to be under the
program's control, and which previously was.  I'm actually investigating
how to make programs cope with the unpredictable situation caused by
this mechanism with the unpredictable environment setting.

-zefram





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#22902: GUILE_INSTALL_LOCALE not equivalent to setlocale
  2016-03-04  3:34 bug#22902: GUILE_INSTALL_LOCALE not equivalent to setlocale Zefram
@ 2016-06-20 16:16 ` Andy Wingo
  2016-08-07 21:53 ` Andy Wingo
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Wingo @ 2016-06-20 16:16 UTC (permalink / raw)
  To: Zefram; +Cc: 22902

On Fri 04 Mar 2016 04:34, Zefram <zefram@fysh.org> writes:

> The documentation claims that setting GUILE_INSTALL_LOCALE=1 in the
> environment is equivalent to calling (setlocale LC_ALL "") at startup.
> Actually there is at least one difference: calling setlocale causes ports
> (both primordial and later-opened) to be initially configured for the
> locale's nominal character encoding, but setting the environment variable
> does not.  Setting the environment variable leaves the port encoding at
> #f, functioning as ISO-8859-1, just as if locale had not been invoked
> at all.  I do see some effects from setting the environment variable,
> specifically message strings affecting strftime.

Indeed!  Thank you for this analysis; I was wondering why I was getting
terrible backtraces in Guile master.

Andy





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#22902: GUILE_INSTALL_LOCALE not equivalent to setlocale
  2016-03-04  3:34 bug#22902: GUILE_INSTALL_LOCALE not equivalent to setlocale Zefram
  2016-06-20 16:16 ` Andy Wingo
@ 2016-08-07 21:53 ` Andy Wingo
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Wingo @ 2016-08-07 21:53 UTC (permalink / raw)
  To: Zefram; +Cc: 22902-done

On Fri 04 Mar 2016 04:34, Zefram <zefram@fysh.org> writes:

> The documentation claims that setting GUILE_INSTALL_LOCALE=1 in the
> environment is equivalent to calling (setlocale LC_ALL "") at startup.
> Actually there is at least one difference: calling setlocale causes ports
> (both primordial and later-opened) to be initially configured for the
> locale's nominal character encoding, but setting the environment variable
> does not.  Setting the environment variable leaves the port encoding at
> #f, functioning as ISO-8859-1, just as if locale had not been invoked
> at all.  I do see some effects from setting the environment variable,
> specifically message strings affecting strftime.

I believe this is fixed in both 2.0 and master.  Thanks for the report.

Andy





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-08-07 21:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-04  3:34 bug#22902: GUILE_INSTALL_LOCALE not equivalent to setlocale Zefram
2016-06-20 16:16 ` Andy Wingo
2016-08-07 21:53 ` Andy Wingo

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