X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fcharnames.pm;h=875c0a5a943fa9e01d97154e9736484e1adb5c1a;hb=2a9e2f8aa1589e1927a7c3f765020dfe0e8bf29f;hp=934fafddd5ff8f5e0e95edaa6d3702d3376c51cd;hpb=b75c8c73cd7f3c92a16e03fb046f4e2a99363bc7;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/charnames.pm b/lib/charnames.pm index 934fafd..875c0a5 100644 --- a/lib/charnames.pm +++ b/lib/charnames.pm @@ -33,8 +33,11 @@ sub charnames { } } die "Unknown charname '$name'" unless @off; - - my $ord = hex substr $txt, $off[0] - 4, 4; + + 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; return chr $ord if $ord <= 255;