This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
APItest:t/utf8_setup.pl: Display printables as themselves
authorKarl Williamson <khw@cpan.org>
Mon, 5 Feb 2018 04:44:17 +0000 (21:44 -0700)
committerKarl Williamson <khw@cpan.org>
Mon, 5 Feb 2018 05:39:37 +0000 (22:39 -0700)
Instead of the harder to read \xXX

ext/XS-APItest/t/utf8_setup.pl

index ec7a5ce..231b4d9 100644 (file)
@@ -11,7 +11,11 @@ sub isASCII { ord "A" == 65 }
 sub display_bytes_no_quotes {
     use bytes;
     my $string = shift;
-    return join("", map { sprintf("\\x%02x", ord $_) } split "", $string)
+    return join("", map {
+                          ($_ =~ /[[:print:]]/)
+                          ? $_
+                          : sprintf("\\x%02x", ord $_)
+                        } split "", $string)
 }
 
 sub display_bytes {