~ruther/guix-local

843568cabe308391b8c5779f5674db8faff4f998 — Tomas Volf 1 year, 6 months ago 24f0d5d
gexp: Improve support of Unicode characters.

Support for non-ASCII characters was mixed.  Some gexp forms did support them,
while others did not.  Combined with current value for
%default-port-conversion-strategy, that sometimes led to unpleasant surprises.

Fixes #73660, see <https://issues.guix.gnu.org/73660>.

* guix/gexp.scm (gexp->derivation): Default LC_CTYPE to C.UTF-8.
(gexp->script, text-file*): Set port encoding to UTF-8.

Change-Id: Ie92a57fe1c3b45d1c7a5e8865fcf291c5f590c11
Signed-off-by: Janneke Nieuwenhuizen <janneke@gnu.org>
1 files changed, 5 insertions(+), 1 deletions(-)

M guix/gexp.scm
M guix/gexp.scm => guix/gexp.scm +5 -1
@@ 5,6 5,7 @@
;;; Copyright © 2019, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2021, 2022 Maxime Devos <maximedevos@telenet.be>
;;; Copyright © 2025 Tomas Volf <~@wolfsden.cz>
;;;
;;; This file is part of GNU Guix.
;;;


@@ 1155,7 1156,7 @@ derivations--e.g., code evaluated for its side effects."
                           #:key
                           system (target 'current)
                           hash hash-algo recursive?
                           (env-vars '())
                           (env-vars '(("LC_CTYPE" . "C.UTF-8")))
                           (modules '())
                           (module-path %load-path)
                           (guile-for-build (%guile-for-build))


@@ 2024,6 2025,8 @@ imported modules in its search path.  Look up EXP's modules in MODULE-PATH."
                      (gexp
                       (call-with-output-file (ungexp output)
                         (lambda (port)
                           (set-port-encoding! port "UTF-8")

                           ;; Note: that makes a long shebang.  When the store
                           ;; is /gnu/store, that fits within the 128-byte
                           ;; limit imposed by Linux, but that may go beyond


@@ 2122,6 2125,7 @@ resulting store file holds references to all these."
  (define builder
    (gexp (call-with-output-file (ungexp output "out")
            (lambda (port)
              (set-port-encoding! port "UTF-8")
              (display (string-append (ungexp-splicing text)) port)))))

  (gexp->derivation name builder