GNU bug report logs - #49082
[PATCH] guix: gexp: Make UTF-8 a default port encoding in mixed-text-file

Previous Next

Package: guix-patches;

Reported by: Andrew Tropin <andrew <at> trop.in>

Date: Fri, 18 Jun 2021 04:33:01 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#49082: closed ([PATCH] guix: gexp: Make UTF-8 a default port
 encoding in mixed-text-file)
Date: Wed, 23 Jun 2021 21:40:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Wed, 23 Jun 2021 23:39:25 +0200
with message-id <875yy4uupe.fsf <at> gnu.org>
and subject line Re: bug#49082: [PATCH] guix: gexp: Make UTF-8 a default port encoding in mixed-text-file
has caused the debbugs.gnu.org bug report #49082,
regarding [PATCH] guix: gexp: Make UTF-8 a default port encoding in mixed-text-file
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
49082: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=49082
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Andrew Tropin <andrew <at> trop.in>
To: guix-patches <at> gnu.org
Subject: [PATCH] guix: gexp: Make UTF-8 a default port encoding in
 mixed-text-file
Date: Fri, 18 Jun 2021 07:15:36 +0300
guix/gexp.scm (mixed-text-file): It's necessary because if some UTF-8 symbols
appear in configuration, resulting file in the store will contain ? instead of
it.
---
 guix/gexp.scm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/guix/gexp.scm b/guix/gexp.scm
index afb935761e..187f5c5e85 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -1921,6 +1921,7 @@ This is the declarative counterpart of 'text-file*'."
   (define build
     (gexp (call-with-output-file (ungexp output "out")
             (lambda (port)
+              (set-port-encoding! port "UTF-8")
               (display (string-append (ungexp-splicing text)) port)))))
 
   (computed-file name build))
-- 
2.32.0



[Message part 3 (message/rfc822, inline)]
From: Ludovic Courtès <ludo <at> gnu.org>
To: Andrew Tropin <andrew <at> trop.in>
Cc: 49082-done <at> debbugs.gnu.org
Subject: Re: bug#49082: [PATCH] guix: gexp: Make UTF-8 a default port
 encoding in mixed-text-file
Date: Wed, 23 Jun 2021 23:39:25 +0200
Hi,

Andrew Tropin <andrew <at> trop.in> skribis:

> guix/gexp.scm (mixed-text-file): It's necessary because if some UTF-8 symbols
> appear in configuration, resulting file in the store will contain ? instead of
> it.

Good catch!  Applied as 1f3d7b45349d43e5cc02594083e0cd44ef730992.

Please look how I modified the commit log, in line with our conventions
and previous entries for this file.

>    (define build
>      (gexp (call-with-output-file (ungexp output "out")
>              (lambda (port)
> +              (set-port-encoding! port "UTF-8")

Leo is right that we’d often write:

  (parameterize ((%default-port-encoding "UTF-8"))
    (call-with-output-file …))

because it’s marginally cleaner (the port is created with the right
encoding from the start).  In this case it doesn’t matter much though.

Thank you!

Ludo’.


This bug report was last modified 3 years and 331 days ago.

Previous Next


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