This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Use hex instead of octal for larger code points
authorKarl Williamson <khw@khw-desktop.(none)>
Sat, 21 Nov 2009 00:14:30 +0000 (17:14 -0700)
committerRafael Garcia-Suarez <rgs@consttype.org>
Mon, 23 Nov 2009 10:43:32 +0000 (11:43 +0100)
t/test.pl

index 7d1a90b..bb27794 100644 (file)
--- a/t/test.pl
+++ b/t/test.pl
@@ -158,7 +158,16 @@ sub display {
                     $y = $y . $backslash_escape{$c};
                 } else {
                     my $z = chr $c; # Maybe we can get away with a literal...
-                    $z = sprintf "\\%03o", $c if $z =~ /[[:^print:]]/;
+                    if ($z =~ /[[:^print:]]/) {
+
+                        # Use octal for characters traditionally expressed as
+                        # such: the low controls
+                        if ($c <= 037) {
+                            $z = sprintf "\\%03o", $c;
+                        } else {
+                            $z = sprintf "\\x{%x}", $c;
+                        }
+                    }
                     $y = $y . $z;
                 }
             }