#! perl -wl # # Print out Iroha table # # Copyright 2016 Ken Takusagawa # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . open FI,"hiragana.txt" or die; while(){ die unless /^(\S+)\s+HIRAGANA LETTER (\S+)/; $hira{$2}=$1; } close FI; open FI,"katakana.txt" or die; while(){ die unless /^(\S+)\s+KATAKANA LETTER (\S+)/; $kata{$2}=$1; } close FI; open FI,"iroha.txt" or die; while(){ @F=split; for(@F){ for(uc$_){ push @iroha,$_; die $_ unless defined($hira{$_}); die $_ unless defined($kata{$_}); }}} print'

'; for(@iroha){ printf " %d",&dec($kata{$_}); #,' ',&dec($kata{$_})-&dec($hira{$_}); } print'

'; for ('A'..'Z') { next if $_ eq 'I'; push @go_coordinates,$_; } for(1..100){ push @go_coordinates,""; #pad } #10 stored as 0 @numerals_hex=qw/5341 4E00 4E8C 4E09 56DB 4E94 516D 4E03 516B 4E5D/; for(@numerals_hex){ push @numerals,("&#".&dec($_).";"); } print qq(); print ""; for($i=0;$i<@iroha;++$i){ $v=$iroha[$i]; $iindex{$v}=$i; print "" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,""; } print "
IrohaNumJnumHiraHira decimalHira hexKataKata decimalKata hexGoZero
$v",$i+1,"",&japanese_number($i+1),"&#",&dec($hira{$v}),";",&dec($hira{$v}),"U+",$hira{$v},"&#",&dec($kata{$v}),";",&dec($kata{$v}),"U+",$kata{$v},"$go_coordinates[$i]$i
"; print qq(); print ""; for$v(sort {&dec($hira{$a}) <=> &dec($hira{$b})} @iroha){ $i=$iindex{$v}; print "" ,"" ,"" ,"" ,"" ,"" ,"" ,"" ,""; }; print "
IrohaNumJnumHiraHira decimalHira hexKataKata decimalKata hexGoZero
$v",$i+1,"",&japanese_number($i+1),"&#",&dec($hira{$v}),";",&dec($hira{$v}),"U+",$hira{$v},"&#",&dec($kata{$v}),";",&dec($kata{$v}),"U+",$kata{$v},"$go_coordinates[$i]$i
"; sub dec { my $s=shift; unpack "n",(pack "H*",$s); } sub japanese_number { my $i=shift; my $out; $ones=$i % 10; $tens=($i-$ones)/10; if($tens){ if($tens>1){ $out=$numerals[$tens]; } $out.=$numerals[0]; #ten; } if($ones){ $out.=$numerals[$ones]; } $out; }