unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#22750: Output port encoding isn't correctly set
@ 2016-02-20 15:56 Roland Lutz
  2016-02-26 18:53 ` Mark H Weaver
  0 siblings, 1 reply; 2+ messages in thread
From: Roland Lutz @ 2016-02-20 15:56 UTC (permalink / raw)
  To: 22750

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1795 bytes --]

Hi,

I've encountered a behavior in Guile 2.0.11 which I believe is a bug. 
When running Guile in a UTF-8 locale, I'd expect that the output port 
encoding is set to UTF-8 unless specified otherwise.  However, it appears 
to be not set at all.

This is my locale:

---
$ locale
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
---

When I try to output non-ASCII characters without manually setting the 
output port encoding to "UTF-8", they aren't printed correctly:

---
$ cat > tmp.scm
(display "…\n")
$ guile -s tmp.scm
;;; [compilation notes]
?
---

When I set the output port encoding to "UTF-8", it works as expected:

---
$ cat > tmp.scm
(set-port-encoding! (current-output-port) "utf-8")
(display "…\n")
$ guile -s tmp.scm
;;; [compilation notes]
…
---

Adding "; coding: utf-8" to the top of the source file doesn't change 
anything.

When querying the output port encoding, it returns "#f":

---
$ cat > tmp.scm
(display (port-encoding (current-output-port)))
(newline)
$ guile -s tmp.scm
;;; [compilation notes]
#f
---

In an interactive session, the output port encoding is set correctly:

---
$ guile
GNU Guile 2.0.11
Copyright (C) 1995-2014 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> (port-encoding (current-output-port))
$1 = "UTF-8"
---

Roland

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

* bug#22750: Output port encoding isn't correctly set
  2016-02-20 15:56 bug#22750: Output port encoding isn't correctly set Roland Lutz
@ 2016-02-26 18:53 ` Mark H Weaver
  0 siblings, 0 replies; 2+ messages in thread
From: Mark H Weaver @ 2016-02-26 18:53 UTC (permalink / raw)
  To: Roland Lutz; +Cc: control, 22750

tags 22750 + notabug
close 22750
thanks

Roland Lutz <rlutz@hedmen.org> writes:
> I've encountered a behavior in Guile 2.0.11 which I believe is a
> bug. When running Guile in a UTF-8 locale, I'd expect that the output
> port encoding is set to UTF-8 unless specified otherwise.  However, it
> appears to be not set at all.

In Guile 2.0.x, as in C, the locale is not set until you set it using
'setlocale'.  To set the locale according to the standard environment
variables, put this at the beginning of your script:

  (setlocale LC_ALL "")

Note that in Guile 2.2.x, the locale will automatically be set when
running a script using the standard 'guile' executable, although
programs linked with libguile will still need to set the locale
explicitly.

     Regards,
       Mark





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

end of thread, other threads:[~2016-02-26 18:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-20 15:56 bug#22750: Output port encoding isn't correctly set Roland Lutz
2016-02-26 18:53 ` Mark H Weaver

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