This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
UCD.pm: All code points are in some block
authorKarl Williamson <public@khwilliamson.com>
Fri, 4 Mar 2011 02:10:06 +0000 (19:10 -0700)
committerKarl Williamson <public@khwilliamson.com>
Fri, 4 Mar 2011 02:26:17 +0000 (19:26 -0700)
Code points that are not in a block are considered to be in the
pseudo-block 'No_Block' by the Unicode standard; so change to do that
instead of 'undef'

lib/Unicode/UCD.pm
lib/Unicode/UCD.t

index b15b927..30acd50 100644 (file)
@@ -530,13 +530,12 @@ sub charblock {
     my $code = _getcode($arg);
 
     if (defined $code) {
-       _search(\@BLOCKS, 0, $#BLOCKS, $code);
-    } else {
-       if (exists $BLOCKS{$arg}) {
-           return dclone $BLOCKS{$arg};
-       } else {
-           return;
-       }
+       my $result = _search(\@BLOCKS, 0, $#BLOCKS, $code);
+        return $result if defined $result;
+        return 'No_Block';
+    }
+    elsif (exists $BLOCKS{$arg}) {
+        return dclone $BLOCKS{$arg};
     }
 }
 
index 0069751..9c57f38 100644 (file)
@@ -17,7 +17,7 @@ use strict;
 use Unicode::UCD;
 use Test::More;
 
-BEGIN { plan tests => 270 };
+BEGIN { plan tests => 271 };
 
 use Unicode::UCD 'charinfo';
 
@@ -219,6 +219,7 @@ use Unicode::UCD qw(charblock charscript);
 
 is(charblock(0x590),          'Hebrew', '0x0590 - Hebrew unused charblock');
 is(charscript(0x590),         'Unknown',    '0x0590 - Hebrew unused charscript');
+is(charblock(0x1FFFF),        'No_Block', '0x1FFFF - unused charblock');
 
 $charinfo = charinfo(0xbe);