[Debconf-devel] Bug#566954: Dialog frontend cannot display literal '\n'

Ben Hutchings ben at decadent.org.uk
Wed Jan 27 01:19:35 UTC 2010


On Tue, 2010-01-26 at 13:27 -0500, Joey Hess wrote:
> Ben Hutchings wrote:
> > The dialog and whiptail programs support the escape sequence '\n'
> > which is converted to a new-line.  However they do not provide any way
> > of printing this character sequence literally.
> 
> What a wonderful er, feature for dialog to have. :-P
> 
> > Inserting the zero-width joiner U+2060 between the two characters
> > seems to be a valid workaround.  However, I was unable to implement
> > this fix in Dialog.pm as that character is lost somewhere on the way
> > to execve().  I don't understand Perl's handling of character
> > encodings well enough to solve this myself.
> 
> Can you send the patch you tried?

--- a/Debconf/FrontEnd/Dialog.pm
+++ b/Debconf/FrontEnd/Dialog.pm
@@ -163,7 +163,13 @@
 	my $lines = $this->screenheight;
 	my ($text, $height, $width)=$this->sizetext($intext);
 
-	my @lines = split(/\n/, $text);
+	sub hide_escape {
+	    my $line = $_;
+	    $line =~ s/\\n/\\\xe2\x81\xa0n/g;
+	    return $line;
+	}
+
+	my @lines = map(&hide_escape, split(/\n/, $text));
 	my $num;
 	my @args=('--msgbox', join("\n", @lines));
 	if ($lines - 4 - $this->borderheight <= $#lines) {
--- END ---

I also tried writing the ZWJ character as \x{2060}.

Ben.

-- 
Ben Hutchings
Any smoothly functioning technology is indistinguishable from a rigged demo.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 828 bytes
Desc: This is a digitally signed message part
URL: <http://lists.alioth.debian.org/pipermail/debconf-devel/attachments/20100127/569d51f4/attachment.pgp>


More information about the Debconf-devel mailing list