w3m

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

mk_hkscs_ucs_p2_map.pl (1292B)


      1 
      2 @NAME = ();
      3 while(<DATA>) {
      4 	chop;
      5 	s/\s+$//;
      6 	(($n, $m, $d) = split(" ", $_, 3)) >= 3 || next;
      7 	push(@NAME, $n);
      8 	$MAP{$n} = $m;
      9 	$DESC{$n} = $d;
     10 }
     11 
     12 %to_ucs = ();
     13 %from_ucs = ();
     14 
     15 foreach $name (@NAME) {
     16 
     17 $map = $MAP{$name};
     18 $desc = $DESC{$name};
     19 print STDERR "$name\t$map\t$desc\n";
     20 
     21 open(MAP, "< $map");
     22 while(<MAP>) {
     23 	(($c, $u) = split(" ")) || next;
     24 	$c = hex($c);
     25 	$u = hex($u);
     26 	if (($c < 0xA140 || $c > 0xF9FE) &&
     27 	    ($u > 0x20000)) {
     28 		$u &= 0xFFFF;
     29 		$to_ucs{$c} = $u;
     30 		$from_ucs{$u} = $c;
     31 	}
     32 }
     33 close(MAP);
     34 
     35 }
     36 
     37 $name = $NAME[0];
     38 $desc = $DESC{$name};
     39 
     40 open(OUT, "> ${name}_ucs_p2.map");
     41 
     42 @ucs = sort { $a <=> $b } keys %to_ucs;
     43 $nucs = @ucs + 0;
     44 
     45 print OUT <<EOF;
     46 /* $desc */
     47 
     48 #define N_${name}_ucs_p2_map $nucs
     49 /*
     50     HKSCS   UCS - 0x20000
     51 */
     52 static wc_map ${name}_ucs_p2_map[ N_${name}_ucs_p2_map ] = {
     53 EOF
     54 for(@ucs) {
     55   $x = $to_ucs{$_};
     56   printf OUT "  { 0x%.4X, 0x%.4X },\n", $_, $x;
     57 }
     58 
     59 @ucs = sort { $a <=> $b } keys %from_ucs;
     60 $nucs = @ucs + 0;
     61 
     62 print OUT <<EOF;
     63 };
     64 
     65 #define N_ucs_p2_${name}_map $nucs
     66 /*
     67     UCS - 0x20000   HKSCS
     68 */
     69 static wc_map ucs_p2_${name}_map[ N_ucs_p2_${name}_map ] = {
     70 EOF
     71 for(@ucs) {
     72   $x = $from_ucs{$_};
     73   printf OUT "  { 0x%.4X, 0x%.4X },\n", $_, $x;
     74 }
     75 
     76 print OUT <<EOF;
     77 };
     78 EOF
     79 
     80 __END__
     81 hkscs	private/hkscs_p2.txt	HKSCS (Chinese Hong Kong)