From fe252ba7bd4499b9e908b90f04e554cc5ba383df Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Mon, 26 Mar 2012 12:04:22 -0600 Subject: [PATCH] Unicode::UCD: Fix blocks to work on early Unicodes Not all Unicode releases supported blocks --- lib/Unicode/UCD.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/Unicode/UCD.pm b/lib/Unicode/UCD.pm index 7d87e42..cdc08a0 100644 --- a/lib/Unicode/UCD.pm +++ b/lib/Unicode/UCD.pm @@ -546,7 +546,8 @@ With a L charblock() returns the I the code point belongs to, e.g. C. The old-style block name is returned (see L). If the code point is unassigned, this returns the block it would belong to if -it were assigned. +it were assigned. (If the Unicode version being used is so early as to not +have blocks, all code points are considered to be in C.) See also L. @@ -572,7 +573,13 @@ sub _charblocks { # Can't read from the mktables table because it loses the hyphens in the # original. unless (@BLOCKS) { - if (openunicode(\$BLOCKSFH, "Blocks.txt")) { + UnicodeVersion() unless defined $v_unicode_version; + if ($v_unicode_version lt v2.0.0) { + my $subrange = [ 0, 0x10FFFF, 'No_Block' ]; + push @BLOCKS, $subrange; + push @{$BLOCKS{$3}}, $subrange; + } + elsif (openunicode(\$BLOCKSFH, "Blocks.txt")) { local $_; local $/ = "\n"; while (<$BLOCKSFH>) { -- 1.8.3.1