summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2011-03-01 07:45:45 -0700
committerKarl Williamson <public@khwilliamson.com>2011-03-01 09:24:27 -0700
commit3a12600d2bffd729b39dced7161579719e50a0c8 (patch)
treec6f8a6b6fbf9c4d7de602e75a181918c2aecaa8e /lib
parentcc27c8a1158ab82e0667a4f22a277a1325b8d5d6 (diff)
downloadperl-3a12600d2bffd729b39dced7161579719e50a0c8.tar.gz
UCD.pm: Add internal fcn for reading mktables file
Diffstat (limited to 'lib')
-rw-r--r--lib/Unicode/UCD.pm33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/Unicode/UCD.pm b/lib/Unicode/UCD.pm
index 04c1fca538..de60ce3eee 100644
--- a/lib/Unicode/UCD.pm
+++ b/lib/Unicode/UCD.pm
@@ -411,6 +411,39 @@ sub _search { # Binary search in a [[lo,hi,prop],[...],...] table.
}
}
+sub _read_table {
+
+ # Returns the contents of the mktables generated table file located at $1
+ # in the form of an array of arrays. Each outer array denotes a range
+ # with [0] the start point of that range; [1] the end point; and [2] the
+ # value that every code point in the range has.
+ #
+ # This has the side effect of setting
+ # $utf8::SwashInfo{$property}{'format'} to be the mktables format of the
+ # table; and
+ # $utf8::SwashInfo{$property}{'missing'} to be the value for all entries
+ # not listed in the table.
+ # where $property is the Unicode property name, preceded by 'To' for map
+ # properties., e.g., 'ToSc'.
+ #
+ # Table entries look like one of:
+ # 0000 0040 Common # [65]
+ # 00AA Latin
+
+ my $table = shift;
+ my @return;
+ local $_;
+
+ for (split /^/m, do $table) {
+ my ($start, $end, $value) = / ^ (.+?) \t (.*?) \t (.+?)
+ \s* ( \# .* )? # Optional comment
+ $ /x;
+ $end = $start if $end eq "";
+ push @return, [ hex $start, hex $end, $value ];
+ }
+ return @return;
+}
+
sub charinrange {
my ($range, $arg) = @_;
my $code = _getcode($arg);