view findUnicode.pl @ 1:6ca82c74bf63

fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 15 Jun 2013 14:16:00 +0900
parents
children 7f5d4dad9d6b
line wrap: on
line source

#!/usr/bin/perl

# find used unicode 
use strict;
use utf8;
use open qw(:std :utf8); # input/output default encoding will be UTF-8, it looks like default

my %used;

while(<>) {
    for my $ch ( /(.)/g ) {
        $used{ord($ch)}++;
    }
}

for my $bdf (<*.bdf>) {
   open(my $f,"<",$bdf);
   my %has;
   while(<$f>) {
       if (/^ENCODING\s+(\d+)/) {    
          my $encoding=$1;
          $has{$encoding} = 1;
       }
   }
   my %no;
   for my $ch ( keys %used ) {
      $no{$ch} ++ if (! defined $has{$ch}) ;
   }
   for my $ch ( sort {$a<=>$b} keys %no ) {
       print "$ch is not in $bdf\n";
   }
}