This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [PATCH] fix for charnames above FFFF
[perl5.git] / lib / charnames.pm
index 0d66308..875c0a5 100644 (file)
@@ -34,8 +34,9 @@ sub charnames {
   }
   die "Unknown charname '$name'" unless @off;
 
-  my $hexlen = 0;
-  $hexlen++ while substr($txt, $off[0] - $hexlen - 1, 1) =~ /[0-9a-f]/;
+  my $hexlen = 4; # Unicode guarantees 4-, 5-, or 6-digit format
+  $hexlen++ while
+      $hexlen < 6 && substr($txt, $off[0] - $hexlen - 1, 1) =~ /[0-9a-f]/;
   my $ord = hex substr $txt, $off[0] - $hexlen, $hexlen;
   if ($^H & $bytes::hint_bits) {       # "use bytes" in effect?
     use bytes;