summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-07-29 20:38:09 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-07-29 20:38:09 +0000
commite63dbbf9f3d8e42e84c45da74ef3054a1717b583 (patch)
tree01527e02d717d663d5789c66b975604001fa72d0
parent6e372064538a0dc06b9a98269040d4ed7c69c393 (diff)
downloadperl-e63dbbf9f3d8e42e84c45da74ef3054a1717b583.tar.gz
Use Search::Dict 1.02 interface for charinfo().
p4raw-id: //depot/perl@11486
-rw-r--r--lib/UnicodeCD.pm12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/UnicodeCD.pm b/lib/UnicodeCD.pm
index 2e01a74b65..ca292efed9 100644
--- a/lib/UnicodeCD.pm
+++ b/lib/UnicodeCD.pm
@@ -246,21 +246,23 @@ sub charinfo {
my $code = _getcode($arg);
croak __PACKAGE__, "::charinfo: unknown code '$arg'"
unless defined $code;
- my $hexk = sprintf("%04X", $code);
+ my $hexk = sprintf("%06X", $code);
my($rcode,$rname,$rdec);
foreach my $range (@CharinfoRanges){
if ($range->[0] <= $code && $code <= $range->[1]) {
$rcode = $hexk;
+ $rcode =~ s/^0+//;
+ $rcode = sprintf("%04X", hex($rcode));
$rname = $range->[2] ? $range->[2]->($code) : '';
$rdec = $range->[3] ? $range->[3]->($code) : '';
- $hexk = sprintf("%04X", $range->[0]); # replace by the first
+ $hexk = sprintf("%06X", $range->[0]); # replace by the first
last;
}
}
openunicode(\$UNICODEFH, "Unicode.txt");
if (defined $UNICODEFH) {
- use Search::Dict;
- if (look($UNICODEFH, "$hexk;")) {
+ use Search::Dict 1.02;
+ if (look($UNICODEFH, "$hexk;", { xfrm => sub { $_[0] =~ /^([^;]+);(.+)/; sprintf "%06X;$2", hex($1) } } ) >= 0) {
my $line = <$UNICODEFH>;
chomp $line;
my %prop;
@@ -271,6 +273,8 @@ sub charinfo {
mirrored unicode10 comment
upper lower title
)} = split(/;/, $line, -1);
+ $hexk =~ s/^0+//;
+ $hexk = sprintf("%04X", hex($hexk));
if ($prop{code} eq $hexk) {
$prop{block} = charblock($code);
$prop{script} = charscript($code);