summaryrefslogtreecommitdiff
path: root/lib/charnames.pm
diff options
context:
space:
mode:
authorSADAHIRO Tomoyuki <BQW10602@nifty.com>2002-05-31 08:56:51 +0900
committerJarkko Hietaniemi <jhi@iki.fi>2002-05-30 14:03:24 +0000
commit94ec6410737406e8f52c36270d784db8d61e0145 (patch)
treedf19568296eea52f97f726ef198feaa014cd75a5 /lib/charnames.pm
parent9903068fee98d1547bedf924c24be413aeb2d9fb (diff)
downloadperl-94ec6410737406e8f52c36270d784db8d61e0145.tar.gz
[Patch perl@16861] charnames::vianame tweak
Message-Id: <20020530235541.D722.BQW10602@nifty.com> p4raw-id: //depot/perl@16890
Diffstat (limited to 'lib/charnames.pm')
-rw-r--r--lib/charnames.pm15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/charnames.pm b/lib/charnames.pm
index af33c86abc..e3d06f3f7f 100644
--- a/lib/charnames.pm
+++ b/lib/charnames.pm
@@ -235,8 +235,19 @@ sub vianame
$txt = do "unicore/Name.pl" unless $txt;
- if ($txt =~ m/^([0-9A-F]+)\t\t($arg)$/m) {
- return $vianame{$arg} = hex $1;
+ my $pos = index $txt, "\t\t$arg\n";
+ if ($[ <= $pos) {
+ my $posLF = rindex $txt, "\n", $pos;
+ (my $code = substr $txt, $posLF + 1, 6) =~ tr/\t//d;
+ return $vianame{$arg} = hex $code;
+
+ # If $pos is at the 1st line, $posLF must be $[ - 1 (not found);
+ # then $posLF + 1 equals to $[ (at the beginning of $txt).
+ # Otherwise $posLF is the position of "\n";
+ # then $posLF + 1 must be the position of the next to "\n"
+ # (the beginning of the line).
+ # substr($txt, $posLF + 1, 6) may be "0000\t\t", "00A1\t\t",
+ # "10300\t", "100000", etc. So we can get the code via removing TAB.
} else {
return;
}