From 843568cabe308391b8c5779f5674db8faff4f998 Mon Sep 17 00:00:00 2001 From: Tomas Volf <~@wolfsden.cz> Date: Thu, 23 Jan 2025 23:57:06 +0100 Subject: [PATCH] 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 . * 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 --- guix/gexp.scm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/guix/gexp.scm b/guix/gexp.scm index 0dcb4b2c8033a9eaddf38fbdeaaacfaf7b376e83..e985e6b4224b97a946eed1451834bf09d94f46c7 100644 --- a/guix/gexp.scm +++ b/guix/gexp.scm @@ -5,6 +5,7 @@ ;;; Copyright © 2019, 2020 Mathieu Othacehe ;;; Copyright © 2020 Maxim Cournoyer ;;; Copyright © 2021, 2022 Maxime Devos +;;; 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