[perl #21839] perluniintro.pod: nice_string() doesn't escape
Jarkko Hietaniemi [Sat, 5 Apr 2003 20:38:30 +0000 (20:38 +0000)]
literal escape chars -- use Sadahiro-san's fix(es).

p4raw-id: //depot/perl@19148

pod/perluniintro.pod

index f18cdee..feee902 100644 (file)
@@ -451,7 +451,7 @@ displayed as C<\x..>, and the rest of the characters as themselves:
                sprintf("\\x{%04X}", $_) :  # \x{...}
                chr($_) =~ /[[:cntrl:]]/ ?  # else if control character ...
                sprintf("\\x%02X", $_) :    # \x..
-               chr($_)                     # else as themselves
+               quotemeta(chr($_))          # else quoted or as themselves
          } unpack("U*", $_[0]));           # unpack Unicode characters
    }
 
@@ -459,9 +459,11 @@ For example,
 
    nice_string("foo\x{100}bar\n")
 
-returns:
+returns the string
 
-   "foo\x{0100}bar\x0A"
+   'foo\x{0100}bar\x0A'
+
+which is ready to be printed.
 
 =head2 Special Cases