ui: Gracefully handle Unicode description strings.
Fixes <http://bugs.gnu.org/21536>. Reported by Alex Kost <alezost@gmail.com>. * guix/ui.scm (texi->plain-text): Wrap body in 'with-fluids'. * tests/ui.scm ("package-description-string vs. Unicode"): New test.
This commit is contained in:
parent
75726135ce
commit
08d7e3592f
|
@ -803,7 +803,10 @@ converted to a space; sequences of more than one line break are preserved."
|
||||||
|
|
||||||
(define (texi->plain-text str)
|
(define (texi->plain-text str)
|
||||||
"Return a plain-text representation of texinfo fragment STR."
|
"Return a plain-text representation of texinfo fragment STR."
|
||||||
(stexi->plain-text (texi-fragment->stexi str)))
|
;; 'texi-fragment->stexi' uses a string port so make sure it's a
|
||||||
|
;; Unicode-capable one (see <http://bugs.gnu.org/11197>.)
|
||||||
|
(with-fluids ((%default-port-encoding "UTF-8"))
|
||||||
|
(stexi->plain-text (texi-fragment->stexi str))))
|
||||||
|
|
||||||
(define (package-description-string package)
|
(define (package-description-string package)
|
||||||
"Return a plain-text representation of PACKAGE description field."
|
"Return a plain-text representation of PACKAGE description field."
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#:use-module (guix profiles)
|
#:use-module (guix profiles)
|
||||||
#:use-module (guix store)
|
#:use-module (guix store)
|
||||||
#:use-module (guix derivations)
|
#:use-module (guix derivations)
|
||||||
|
#:use-module (guix tests)
|
||||||
#:use-module (srfi srfi-1)
|
#:use-module (srfi srfi-1)
|
||||||
#:use-module (srfi srfi-11)
|
#:use-module (srfi srfi-11)
|
||||||
#:use-module (srfi srfi-19)
|
#:use-module (srfi srfi-19)
|
||||||
|
@ -89,6 +90,12 @@ interface, and powerful string processing.")
|
||||||
(fill-paragraph "First line.
|
(fill-paragraph "First line.
|
||||||
Second line" 24))
|
Second line" 24))
|
||||||
|
|
||||||
|
(test-equal "package-description-string vs. Unicode"
|
||||||
|
"b•ll•t\n\n" ;see <http://bugs.gnu.org/21536>
|
||||||
|
(with-fluids ((%default-port-encoding "ISO-8859-1"))
|
||||||
|
(package-description-string
|
||||||
|
(dummy-package "foo" (description "b•ll•t")))))
|
||||||
|
|
||||||
(test-equal "package-specification->name+version+output"
|
(test-equal "package-specification->name+version+output"
|
||||||
'(("guile" #f "out")
|
'(("guile" #f "out")
|
||||||
("guile" "2.0.9" "out")
|
("guile" "2.0.9" "out")
|
||||||
|
|
Loading…
Reference in New Issue