summaryrefslogtreecommitdiff
path: root/lib/Unicode/Collate.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Unicode/Collate.pm')
-rw-r--r--lib/Unicode/Collate.pm15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/Unicode/Collate.pm b/lib/Unicode/Collate.pm
index 113613e18f..2ffda37faa 100644
--- a/lib/Unicode/Collate.pm
+++ b/lib/Unicode/Collate.pm
@@ -4,7 +4,6 @@ use 5.006;
use strict;
use warnings;
use Carp;
-use Lingua::KO::Hangul::Util;
require Exporter;
our $VERSION = '0.08';
@@ -19,6 +18,15 @@ our @EXPORT = ();
(our $Path = $INC{'Unicode/Collate.pm'}) =~ s/\.pm$//;
our $KeyFile = "allkeys.txt";
+# Lingua::KO::Hangul::Util not part of the standard distribution
+# but it will be used if available.
+
+eval { require Lingua::KO::Hangul::Util };
+my $hasHangulUtil = ! $@;
+if ($hasHangulUtil) {
+ Lingua::KO::Hangul::Util->import();
+}
+
our %Combin; # combining class from Unicode::Normalize
use constant Min2 => 0x20; # minimum weight at level 2
@@ -256,7 +264,10 @@ sub getWt
_isHangul($u)
? $hang
? &$hang($u)
- : map(@{ $ent->{pack('U', $_)} }, decomposeHangul($u))
+ : ($hasHangulUtil ?
+ map(@{ $ent->{pack('U', $_)} }, decomposeHangul($u)) :
+ # runtime compile error...
+ (eval 'use Lingua::KO::Hangul::Util', print $@))
: _isCJK($u)
? $cjk ? &$cjk($u) : map($self->altCE(0,@$_), _CJK($u))
: map($self->altCE(0,@$_), _derivCE($u));