}elsif($^V and $^V ge v5.6){
$perl56=1;
}else{
- print STDERR "This versin is not supported.";
+ print STDERR "This version is not supported.";
}
if($perl58){
eval "use Encode";
($encoding=$cmapfile)=~s!.*/Uni(\w+).*$!"\=ucs\@".lc($1)!e;
}
-unless(-f $cmapfile
+unless(defined($cmapfile) and -f $cmapfile
and $encoding=~/^=ucs\@(cns|gb|jis|ks)$/
and -d $db_home){
print $usage;
exit 1;
}
+$cs_var{'=ucs@cns'}=['=cns11643-1','=cns11643-2',
+ '=cns11643-3','=cns11643-4',
+ '=cns11643-5','=cns11643-6',
+ '=cns11643-7'];
+
+$cs_var{'=ucs@gb'}=['=gb12345','=gb2312'];
+
+$cs_var{'=ucs@jis'}=['=jis-x0208','=jis-x0208-1978',
+ '=jis-x0208-1983','=jis-x0208-1990',
+ '=jis-x0212',
+ '=jis-x0213-1-2000','=jis-x0213-2-2000'];
+
+$cs_var{'=ucs@ks'}=['=ks-x1001'];
+
if(-f "$db_home/$ciddb_filename"){
print STDERR "Removing old DB $db_home/$ciddb_filename.\n";
unlink "$db_home/$ciddb_filename";
}
}
if($debug){
- print STDERR sprintf("%X:%X\n",unpack("U",$char),$cid);
+ print STDERR sprintf("%X:%d\n",unpack("U",$char),$cid);
}
unless($ciddb->db_put("?".$char,$cid)==0){
die $!;
exit 0;
-$cs_var{'=ucs@cns'}=['=cns11643-1','=cns11643-2',
- '=cns11643-3','=cns11643-4',
- '=cns11643-5','=cns11643-6',
- '=cns11643-7'];
-
-$cs_var{'=ucs@gb'}=['=gb12345','=gb2312'];
-
-$cs_var{'=ucs@jis'}=['=jis-x0208','=jis-x0208-1978',
- '=jis-x0208-1983','=jis-x0208-1990',
- '=jis-x0212',
- '=jis-x0213-1-2000','=jis-x0213-2-2000'];
-
-$cs_var{'=ucs@ks'}=['=ks-x1001'];
sub replace_char_id{
my($ucs,$encoding)=@_;
sub have_glyph{
my($char_id,$cs)=@_;
- my($cs_var);
+ my($cs_var,$char);
+ $char=pack("U",$char_id);
foreach $cs_var (@{$cs_var{$cs}}){
- if(&get_char_attribute(pack("U",$char_id),$cs_var)){
+ if(&get_char_attribute($char,$cs_var)){
return 1;
}
}
sub get_char_id_unified{
my($char_id)=@_;
my($chars);
- $chars=&get_char_attribute(pack("U",$char_id),'->ucs-unified');
- $chars=~s/^\((.*)\)$/$1/;
- $chars=~s/\?//g;
- return map {unpack("U",$_)} (split(/\s+/,$chars));
+ if($chars=&get_char_attribute(pack("U",$char_id),'->ucs-unified')){
+ $chars=~s/^\((.*)\)$/$1/;
+ $chars=~s/\?//g;
+ return map {unpack("U",$_)} (split(/\s+/,$chars));
+ }else{
+ return ();
+ }
}