X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fcharnames.pm;h=875c0a5a943fa9e01d97154e9736484e1adb5c1a;hb=2a9e2f8aa1589e1927a7c3f765020dfe0e8bf29f;hp=0ec7ec2d21c70c4ca471c478ac583419f97755d3;hpb=22d4bb9ccb8701e68f9243547d7e3a3c55f70908;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/charnames.pm b/lib/charnames.pm index 0ec7ec2..875c0a5 100644 --- a/lib/charnames.pm +++ b/lib/charnames.pm @@ -1,4 +1,7 @@ package charnames; + +our $VERSION = '1.00'; + use bytes (); # for $bytes::hint_bits use warnings(); $charnames::hint_bits = 0x20000; @@ -30,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;