diff options
Diffstat (limited to 'mkutable')
-rwxr-xr-x | mkutable | 34 |
1 files changed, 25 insertions, 9 deletions
@@ -7,8 +7,9 @@ my $USAGE = <<__EOF__; -f = zero-based type field (default 2) __EOF__ -use vars qw( $opt_f $opt_n ); use Getopt::Std; +use vars qw( $opt_f $opt_n ); + my $type_field = 2; # Override Unicode tables for certain control chars @@ -21,16 +22,20 @@ my %force_space = ( 0x0d => 1, # carriage return ); +# Hangul Jamo medial vowels and final consonants should be zero width. +my @force_compose = ( + [0x1160, 0x11ff], + [0xd7b0, 0xd7c6], + [0xd7cb, 0xd7fb] +); + exit (main() ? 0 : 1); sub main { - my $date = `date`; - chomp $date; my $args = join ' ', @ARGV; - my $header = "/* Generated by \"$0 $args\" on $date */\n"; - die $USAGE if not getopts('f:n'); $type_field = $opt_f if $opt_f; + my %types; my $arg; while ($arg = shift @ARGV) { @@ -39,7 +44,18 @@ sub main { } my %out = ( 'types' => \%types ); - print $header; + my %force_compose; + foreach my $comp (@force_compose) { + my ($lo,$hi) = @$comp; + for (my $ch = $lo; $ch <= $hi; ++$ch) { + $force_compose{$ch} = 1; + } + } + + my $date = `date`; + chomp $date; + print "/* Generated by \"$0 $args\" on $date */\n"; + my $last_code = 0; while (<>) { chomp; @@ -52,13 +68,13 @@ sub main { $lo_code = hex $1; $hi_code = hex $2; } else { - $lo_code = $hi_code = hex $fields[0]; + $lo_code = $hi_code = hex $codes; } my $type = $fields[$type_field]; $type =~ s/\s//g; for ($last_code = $lo_code; $last_code <= $hi_code; ++$last_code) { - $type = 'Zs' if $force_space{$last_code}; - output(\%out, $last_code, $type); + output(\%out, $last_code, + $force_space{$last_code} ? 'Zs' : $force_compose{$last_code} ? 'Mn' : $type); } } output(\%out, $last_code); |