w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

mk_tis_ucs_map.pl (1059B)


      1 
      2 @NAME = ();
      3 while(<DATA>) {
      4   chop;
      5   s/\s*$//;
      6   (($n, $m, $c) = split(" ", $_, 3)) >= 3 || next;
      7   push(@NAME, $n);
      8   $MAP{$n} = $m;
      9   $CODE{$n} = $c;
     10 }
     11 
     12 foreach $name (@NAME) {
     13 
     14 $code = $CODE{$name};
     15 $map = $MAP{$name};
     16 
     17 print "$name\t$map\t$code\n";
     18 
     19 @to_ucs = ();
     20 %from_ucs = ();
     21 open(OUT, "> ${name}_ucs.map");
     22 
     23 for $i (0xA1 .. 0xDA, 0xDF .. 0xFB) {
     24   $u = $i - 0xA0 + 0xE00;
     25   $to_ucs[$i] = $u;
     26   $from_ucs{$u} = $i;
     27 }
     28 
     29 print OUT <<EOF;
     30 /* $code */
     31 
     32 static wc_uint16 ${name}_ucs_map[ 0x80 ] = {
     33 EOF
     34 
     35 foreach $i (0x10 .. 0x1F) {
     36   print OUT " ";
     37 foreach $j (0 .. 7) {
     38   $_ = $i * 8 + $j;
     39   $u = $to_ucs[$_];
     40   if ($u) {
     41     printf OUT " 0x%.4X,", $u;
     42   } else {
     43     print OUT " 0,     ";
     44   }
     45 }
     46   print OUT "\n";
     47 }
     48 
     49 @ucs = sort { $a <=> $b } keys %from_ucs;
     50 $nucs = @ucs + 0;
     51 
     52 print OUT <<EOF;
     53 };
     54 
     55 #define N_ucs_${name}_map $nucs
     56 
     57 static wc_map ucs_${name}_map[ N_ucs_${name}_map ] = {
     58 EOF
     59 for(@ucs) {
     60   printf OUT "  { 0x%.4X, 0x%.2X },\n", $_, $from_ucs{$_};
     61 }
     62 
     63 print OUT <<EOF;
     64 };
     65 EOF
     66 
     67 close(MAP);
     68 }
     69 
     70 __END__
     71 iso885911	-		ISO-8859-11, TIS-620 (Thai)