GNU bug report logs - #22750
Output port encoding isn't correctly set

Previous Next

Package: guile;

Reported by: Roland Lutz <rlutz <at> hedmen.org>

Date: Sat, 20 Feb 2016 18:25:02 UTC

Severity: normal

Tags: notabug

Done: Mark H Weaver <mhw <at> netris.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Roland Lutz <rlutz <at> hedmen.org>
To: 22750 <at> debbugs.gnu.org
Subject: bug#22750: Output port encoding isn't correctly set
Date: Sat, 20 Feb 2016 16:56:47 +0100 (CET)
[Message part 1 (text/plain, inline)]
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

This bug report was last modified 9 years and 115 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.