From: Jarkko Hietaniemi Date: Fri, 7 Dec 2001 14:58:06 +0000 (+0000) Subject: Add display() for displaying icky scalars. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6cb8f8aa0b354a4c64f58414ffb96b4138d3a098;p=p5sagit%2Fp5-mst-13.2.git Add display() for displaying icky scalars. p4raw-id: //depot/perl@13513 --- diff --git a/t/test.pl b/t/test.pl index ca4af68..ac6bbb7 100644 --- a/t/test.pl +++ b/t/test.pl @@ -263,6 +263,12 @@ sub BAILOUT { } +# A way to display scalars containing control characters and Unicode. +sub display { + join("", map { $_ > 255 ? sprintf("\\x{%x}", $_) : chr($_) =~ /[[:cntrl:]]/ ? sprintf("\\%03o", $_) : chr($_) } unpack("U*", $_[0])); +} + + # A somewhat safer version of the sometimes wrong $^X. BEGIN: { eval {