From: Jarkko Hietaniemi Date: Tue, 3 Jul 2001 20:41:54 +0000 (+0000) Subject: Add charscript() to get the UTR#24 script names of characters. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e882dd6753c26e02b7dbf9e7c3e89bae261f600d;p=p5sagit%2Fp5-mst-13.2.git Add charscript() to get the UTR#24 script names of characters. p4raw-id: //depot/perl@11128 --- diff --git a/lib/Unicode/UCD.pm b/lib/Unicode/UCD.pm index 49e80f3..f4a3a64 100644 --- a/lib/Unicode/UCD.pm +++ b/lib/Unicode/UCD.pm @@ -8,7 +8,7 @@ our $VERSION = '3.1.0'; require Exporter; our @ISA = qw(Exporter); -our @EXPORT_OK = qw(charinfo charblock); +our @EXPORT_OK = qw(charinfo charblock charscript); use Carp; @@ -22,10 +22,13 @@ Unicode::UCD - Unicode character database # requires that level of the Unicode character database use Unicode::UCD 'charinfo'; - my %charinfo = charinfo($codepoint); + my %charinfo = charinfo($codepoint); use Unicode::UCD 'charblock'; - my $charblock = charblock($codepoint); + my $charblock = charblock($codepoint); + + use Unicode::UCD 'charscript'; + my $charscript = charblock($codepoint); =head1 DESCRIPTION @@ -36,6 +39,7 @@ Database. my $UNICODE; my $BLOCKS; +my $SCRIPTS; sub openunicode { my ($rfh, @path) = @_; @@ -45,9 +49,11 @@ sub openunicode { use File::Spec; $f = File::Spec->catfile($d, "unicode", @path); last if open($$rfh, $f); + undef $f; } - croak __PACKAGE__, ": failed to find ",join("/",@path)," in @INC\n" - unless defined $rfh; + croak __PACKAGE__, ": failed to find ", + File::Spec->catfile(@path), " in @INC" + unless defined $f; } return $f; } @@ -78,20 +84,22 @@ by the Unicode standard: upper uppercase equivalent mapping lower lowercase equivalent mapping title titlecase equivalent mapping + block block the character belongs to (used in \p{In...}) + script script the character belongs to If no match is found, an empty hash is returned. The C property is the same as as returned by charinfo(). It is not defined in the Unicode Character Database proper (Chapter 4 of the Unicode 3.0 Standard) but instead in an auxiliary database (Chapter 14 -of TUS3). +of TUS3). Similarly for the C