mk_ucs_map.pl (3625B)
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(MAP, "< $map"); 22 open(OUT, "> ${name}_ucs.map"); 23 while(<MAP>) { 24 /^#/ && next; 25 s/#.*//; 26 (($i, $u) = split(" ")) || next; 27 $i = hex($i); 28 $u = hex($u); 29 if ($u >= 0xa0) { 30 $to_ucs[$i] = $u; 31 if ($i < 0x80) { 32 print STDERR "$map $i $u\n"; 33 # $from_ucs{$u} = $i; 34 } else { 35 $from_ucs{$u} = $i; 36 } 37 } 38 } 39 40 # print OUT <<EOF; 41 # /* 42 # These conversion tables between $code and 43 # Unicode were made from 44 # 45 # ftp://ftp.unicode.org/Public/MAPPINGS/$map. 46 # */ 47 # 48 print OUT <<EOF; 49 /* $code */ 50 51 static wc_uint16 ${name}_ucs_map[ 0x80 ] = { 52 EOF 53 54 foreach $i (0x10 .. 0x1F) { 55 print OUT " "; 56 foreach $j (0 .. 7) { 57 $_ = $i * 8 + $j; 58 $u = $to_ucs[$_]; 59 if ($u) { 60 printf OUT " 0x%.4X,", $u; 61 } else { 62 print OUT " 0, "; 63 } 64 } 65 print OUT "\n"; 66 } 67 68 @ucs = sort { $a <=> $b } keys %from_ucs; 69 $nucs = @ucs + 0; 70 71 print OUT <<EOF; 72 }; 73 74 #define N_ucs_${name}_map $nucs 75 76 static wc_map ucs_${name}_map[ N_ucs_${name}_map ] = { 77 EOF 78 for(@ucs) { 79 printf OUT " { 0x%.4X, 0x%.2X },\n", $_, $from_ucs{$_}; 80 } 81 82 print OUT <<EOF; 83 }; 84 EOF 85 86 close(MAP); 87 } 88 89 __END__ 90 jisx0201k EASTASIA/JIS/JIS0201.TXT JIS X 0201 (Japanese Kana) 91 iso88591 ISO8859/8859-1.TXT ISO-8859-1 (Latin 1) 92 iso88592 ISO8859/8859-2.TXT ISO-8859-2 (Latin 2) 93 iso88593 ISO8859/8859-3.TXT ISO-8859-3 (Latin 3) 94 iso88594 ISO8859/8859-4.TXT ISO-8859-4 (Latin 4) 95 iso88595 ISO8859/8859-5.TXT ISO-8859-5 (Cyrillic) 96 iso88596 ISO8859/8859-6.TXT ISO-8859-6 (Arabic) 97 iso88597 ISO8859/8859-7.TXT ISO-8859-7 (Greek) 98 iso88598 ISO8859/8859-8.TXT ISO-8859-8 (Hebrew) 99 iso88599 ISO8859/8859-9.TXT ISO-8859-9 (Latin 5) 100 iso885910 ISO8859/8859-10.TXT ISO-8859-10 (Latin 6) 101 iso885913 ISO8859/8859-13.TXT ISO-8859-13 (Latin 7) 102 iso885914 ISO8859/8859-14.TXT ISO-8859-14 (Latin 8) 103 iso885915 ISO8859/8859-15.TXT ISO-8859-15 (Latin 9) 104 iso885916 ISO8859/8859-16.TXT ISO-8859-16 (Romanian) 105 106 cp856 VENDORS/MISC/CP856.TXT CP856 (Hebrew) 107 cp1006 VENDORS/MISC/CP1006.TXT IBM CP1006 (Arabic) 108 koi8r VENDORS/MISC/KOI8-R.TXT KOI8-R (Cyrillic) 109 110 nextstep VENDORS/NEXT/NEXTSTEP.TXT NeXTSTEP 111 112 cp437 VENDORS/MICSFT/PC/CP437.TXT CP437 (Latin) 113 cp737 VENDORS/MICSFT/PC/CP737.TXT CP737 (Greek) 114 cp775 VENDORS/MICSFT/PC/CP775.TXT CP775 (Baltic Rim) 115 cp850 VENDORS/MICSFT/PC/CP850.TXT CP850 (Latin 1) 116 cp852 VENDORS/MICSFT/PC/CP852.TXT CP852 (Latin 2) 117 cp855 VENDORS/MICSFT/PC/CP855.TXT CP855 (Cyrillic) 118 cp857 VENDORS/MICSFT/PC/CP857.TXT CP857 (Turkish) 119 cp860 VENDORS/MICSFT/PC/CP860.TXT CP860 (Portuguese) 120 cp861 VENDORS/MICSFT/PC/CP861.TXT CP861 (Icelandic) 121 cp862 VENDORS/MICSFT/PC/CP862.TXT CP862 (Hebrew) 122 cp863 VENDORS/MICSFT/PC/CP863.TXT CP863 (Canada French) 123 cp864 VENDORS/MICSFT/PC/CP864.TXT CP864 (Arabic) 124 cp865 VENDORS/MICSFT/PC/CP865.TXT CP865 (Nordic) 125 cp866 VENDORS/MICSFT/PC/CP866.TXT CP866 (Cyrillic Russian) 126 cp869 VENDORS/MICSFT/PC/CP869.TXT CP869 (Greek 2) 127 cp874 VENDORS/MICSFT/PC/CP874.TXT CP874 (Thai) 128 129 cp1250 VENDORS/MICSFT/WINDOWS/CP1250.TXT CP1250 (Latin 2) 130 cp1251 VENDORS/MICSFT/WINDOWS/CP1251.TXT CP1251 (Cyrillic) 131 cp1252 VENDORS/MICSFT/WINDOWS/CP1252.TXT CP1252 (Latin 1) 132 cp1253 VENDORS/MICSFT/WINDOWS/CP1253.TXT CP1253 (Greek) 133 cp1254 VENDORS/MICSFT/WINDOWS/CP1254.TXT CP1254 (Turkish) 134 cp1255 VENDORS/MICSFT/WINDOWS/CP1255.TXT CP1255 (Hebrew) 135 cp1256 VENDORS/MICSFT/WINDOWS/CP1256.TXT CP1256 (Arabic) 136 cp1257 VENDORS/MICSFT/WINDOWS/CP1257.TXT CP1257 (Baltic Rim) 137