janneke pushed a commit to branch core-packages-team
in repository guix.
commit 55f7806234b9a804f35d463e96d389b96a467ac1
Author: Tomas Volf <[email protected]>
AuthorDate: Thu Jan 23 23:57:06 2025 +0100
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 <[email protected]>
---
guix/gexp.scm | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 811cf02a53..3ebbd9beae 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -5,6 +5,7 @@
;;; Copyright © 2019, 2020 Mathieu Othacehe <[email protected]>
;;; Copyright © 2020 Maxim Cournoyer <[email protected]>
;;; Copyright © 2021, 2022 Maxime Devos <[email protected]>
+;;; Copyright © 2025 Tomas Volf <[email protected]>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -1151,7 +1152,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))
@@ -2020,6 +2021,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
@@ -2118,6 +2121,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