From: Andreas König Date: Wed, 21 Feb 2001 07:05:45 +0000 (+0100) Subject: fix for charnames above FFFF X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b896c7a5a6c831ac6dcdfa1bf97349e5249a98b7;p=p5sagit%2Fp5-mst-13.2.git fix for charnames above FFFF Message-ID: p4raw-id: //depot/perl@8873 --- diff --git a/lib/charnames.pm b/lib/charnames.pm index 934fafd..0d66308 100644 --- a/lib/charnames.pm +++ b/lib/charnames.pm @@ -33,8 +33,10 @@ sub charnames { } } die "Unknown charname '$name'" unless @off; - - my $ord = hex substr $txt, $off[0] - 4, 4; + + my $hexlen = 0; + $hexlen++ while 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; diff --git a/t/lib/charnames.t b/t/lib/charnames.t index 388f533..6a8a8be 100644 --- a/t/lib/charnames.t +++ b/t/lib/charnames.t @@ -8,7 +8,7 @@ BEGIN { } $| = 1; -print "1..14\n"; +print "1..15\n"; use charnames ':full'; @@ -42,6 +42,7 @@ EOE $encoded_be = "\320\261"; $encoded_alpha = "\316\261"; $encoded_bet = "\327\221"; +$encoded_deseng = "\360\220\221\215"; sub to_bytes { pack"a*", shift; @@ -96,3 +97,12 @@ sub to_bytes { print "ok 14\n"; } +{ + use charnames ':full'; + + print "not " + unless to_bytes("\N{DESERET SMALL LETTER ENG}") eq $encoded_deseng; + print "ok 15\n"; + +} +