From: Rafael Garcia-Suarez Date: Wed, 7 Sep 2005 11:09:10 +0000 (+0000) Subject: The formatting function of Carp::Heavy has problem with utf8 strings. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e6ddefa8ea3de4bcc18352257210295203bcb7cb;p=p5sagit%2Fp5-mst-13.2.git The formatting function of Carp::Heavy has problem with utf8 strings. Work around it. p4raw-id: //depot/perl@25363 --- diff --git a/lib/Carp/Heavy.pm b/lib/Carp/Heavy.pm index 0180dcf..79aa5f8 100644 --- a/lib/Carp/Heavy.pm +++ b/lib/Carp/Heavy.pm @@ -116,9 +116,10 @@ sub format_arg { $arg = "'$arg'" unless $arg =~ /^-?[\d.]+\z/; # The following handling of "control chars" is direct from - # the original code - I think it is broken on Unicode though. + # the original code - it is broken on Unicode though. # Suggestions? - $arg =~ s/([[:cntrl:]]|[[:^ascii:]])/sprintf("\\x{%x}",ord($1))/eg; + utf8::is_utf8($arg) + or $arg =~ s/([[:cntrl:]]|[[:^ascii:]])/sprintf("\\x{%x}",ord($1))/eg; return $arg; }