From: SADAHIRO Tomoyuki Date: Sat, 4 May 2002 16:07:07 +0000 (+0900) Subject: [Unicode::Collate] UCA Version number X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3164dd77493d8c6d2197a3faf95daafb93006a96;p=p5sagit%2Fp5-mst-13.2.git [Unicode::Collate] UCA Version number Message-Id: <20020504160547.D7E0.BQW10602@nifty.com> p4raw-id: //depot/perl@16398 --- diff --git a/lib/Unicode/Collate.pm b/lib/Unicode/Collate.pm index 6d6ed32..e0dfbd3 100644 --- a/lib/Unicode/Collate.pm +++ b/lib/Unicode/Collate.pm @@ -25,6 +25,29 @@ our @EXPORT = (); (our $Path = $INC{'Unicode/Collate.pm'}) =~ s/\.pm$//; our $KeyFile = "allkeys.txt"; +our $UNICODE_VERSION; + +{ + my($f, $fh); + foreach my $d (@INC) { + use File::Spec; + $f = File::Spec->catfile($d, "unicore", "version"); + if (open($fh, $f)) { + chomp($UNICODE_VERSION = <$fh>); + close $fh; + last; + } + + # XXX, Perl 5.6.1 + $f = File::Spec->catfile($d, "unicode", "Unicode.301"); + if (open($fh, $f)) { + $UNICODE_VERSION = "3.0.1"; + close $fh; + last; + } + } +} + our $getCombinClass; # coderef for combining class from Unicode::Normalize use constant Min2 => 0x20; # minimum weight at level 2 @@ -33,6 +56,10 @@ use constant UNDEFINED => 0xFF80; # special value for undefined CE's our $DefaultRearrange = [ 0x0E40..0x0E44, 0x0EC0..0x0EC4 ]; +sub UCA_Version { "8.0" } + +sub Base_Unicode_Version { $UNICODE_VERSION } + ## ## constructor ## @@ -809,7 +836,7 @@ these tags doesn't work validly. =back -=head2 Other methods +=head2 Methods for Collation =over 4 @@ -913,6 +940,22 @@ is primary equal to C<"m>E<252>C. =back +=head2 Other Methods + +=over 4 + +=item UCA_Version + +Returns the version number of Unicode Technical Standard 10 +this module consults. + +=item Base_Unicode_Version + +Returns the version number of the Unicode Standard +this module is based on. + +=back + =head2 EXPORT None by default. diff --git a/lib/Unicode/Collate/t/test.t b/lib/Unicode/Collate/t/test.t index 957bad1..d6d7288 100644 --- a/lib/Unicode/Collate/t/test.t +++ b/lib/Unicode/Collate/t/test.t @@ -11,12 +11,17 @@ BEGIN { } use Test; -BEGIN { plan tests => 156 }; +BEGIN { plan tests => 160 }; use Unicode::Collate; ok(1); # If we made it this far, we're ok. ######################### +my $UCA_Version = "8.0"; + +ok(Unicode::Collate::UCA_Version, $UCA_Version); +ok(Unicode::Collate->UCA_Version, $UCA_Version); + my $Collator = Unicode::Collate->new( table => 'keys.txt', normalization => undef, @@ -24,6 +29,9 @@ my $Collator = Unicode::Collate->new( ok(ref $Collator, "Unicode::Collate"); +ok($Collator->UCA_Version, $UCA_Version); +ok($Collator->UCA_Version(), $UCA_Version); + ok( join(':', $Collator->sort( qw/ lib strict Carp ExtUtils CGI Time warnings Math overload Pod CPAN / @@ -585,8 +593,8 @@ ok($Collator ->lt("Ca\x{300}ca\x{302}", "ca\x{302}ca\x{300}")); ok($Collator ->lt("ca\x{300}ca\x{302}", "Ca\x{302}ca\x{300}")); -# HIRAGANA and KATAKANA are undefined via ignoreName. -# So they are after CJK Ideographs. +# HIRAGANA and KATAKANA are made undefined via undefName. +# So they are after CJK Unified Ideographs. ok($backLevel2->lt("\x{4E00}", $hiragana)); ok($backLevel2->lt("\x{4E03}", $katakana));