3 # USAGE: perl ksx1001.pl > ksx1001.h
5 # Requires CP949.TXT, found on:
6 # http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP949.TXT"
8 require "cjkcompat.pl";
13 die "${cp949}: File not found.\n" if (!(-f
$cp949));
14 open (SET
, $cp949) or die "${cp949}: $!\n";
21 next unless /^0x([0-9A-F]{2,4})\s+0x([0-9A-F]{4})\s*$/;
23 my ($code, $ucode) = (hex($1), hex($2));
26 print STDERR
"Warning: duplicated: $code->$k2u{$code},$ucode\n"
27 if defined $k2u{$code};
37 print STDERR
"Warning: duplicated: $u2k{$k2u{$_}},$_<-$k2u{$_}\n"
38 if defined $u2k{$k2u{$_}};
41 if ($c1 >= 0xA1 && $c2 >= 0xA1) {
42 $u2k_ksx1001{$k2u{$_}} = $_;
44 $u2k_cp949{$k2u{$_}} = $_;
48 # Add maps for CJK compatibility ideographs of Unicode.
49 ####&add_cjkcompat(%compat_ksx1001);
50 &add_cjkcompat
(%compat_big5);
51 &add_cjkcompat
(%compat_ibm32);
52 &add_cjkcompat
(%compat_jisx0213);
53 &add_cjkcompat
(%compat_cns11643);
57 foreach (keys %compat) {
58 if (defined $u2k_ksx1001{$compat{$_}}) {
59 $u2k_ksx1001{$_} = $u2k_ksx1001{$compat{$_}};
61 if (defined $u2k_cp949{$compat{$_}}) {
62 $u2k_cp949{$_} = $u2k_cp949{$compat{$_}};
72 * KS X 1001 and CP949 (UHC) support
73 * by Hatuka*nezumi - IKEDA Soji <nezumi\@jca.apc.org>
74 * $Id: ksx1001.pl,v 1.1 2004/02/03 02:00:00 mrsam Exp $
80 #define KS_CHAR_SO 0x0E
81 #define KS_CHAR_SI 0x0F
82 #define KS_CHAR_ESC 0x1B
84 /* ISOREG #1/#3: US-ASCII (identical to ISO 646 IRV) */
85 #define KS_STATE_ASCII 0x0
86 /* ISOREG #149: KS X 1001:1992 Wansung */
87 #define KS_STATE_KSX1001 0x4
89 #define KS_STATE_BINARY 0xF
93 print "/* map: CP949 to Unicode */\n";
94 for ($hb = 0x81; $hb <= 0xFE; $hb++) {
96 for ($lb = 0x41; $lb <= 0xFE; $lb++) {
97 $items++ if $k2u{$hb*256 + $lb};
101 printf "static const unicode_char cp949_to_uni_tbl_%02x[] = {", $hb;
102 for ($lb = 0x41; $lb <= 0xFE; $lb++) {
103 $code = $hb*256 + $lb;
104 print ", " if ($items > 0);
105 print "\n " if ($items % $perline == 0);
106 $k2u{$code} = 0xFFFD unless $k2u{$code};
107 printf("0x%04X", $k2u{$code});
115 print "const unicode_char * cp949_to_uni_tbls[] = {\n";
116 for ($hb=0x81; $hb <= 0xFE; $hb++) {
117 print (($hb > 0x81) ?
",\n " : " ");
119 printf "cp949_to_uni_tbl_%02x", $hb;
130 print "/* map: Unicode to KS X 1001 */\n";
131 for ($hb = 0x00; $hb <= 0xFF; $hb++) {
133 for ($lb = 0x00; $lb <= 0xFF; $lb++) {
134 $items++ if $u2k_ksx1001{$hb*256 + $lb};
138 printf "static const unicode_char uni_to_ksx1001_tbl_%02x[] = {", $hb;
139 for ($lb = 0x00; $lb <= 0xFF; $lb++) {
140 $code = $hb*256 + $lb;
141 print ", " if ($items > 0);
142 print "\n " if ($items % $perline == 0);
143 $u2k_ksx1001{$code} = 0x003F unless $u2k_ksx1001{$code};
144 printf("0x%04X", $u2k_ksx1001{$code});
152 print "const unicode_char * uni_to_ksx1001_tbls[] = {\n";
153 for ($hb=0x00; $hb <= 0xFF; $hb++) {
154 print (($hb > 0x00) ?
",\n " : " ");
156 printf "uni_to_ksx1001_tbl_%02x", $hb;
166 print "/* map: Unicode to CP949 extension */\n";
167 for ($hb = 0x00; $hb <= 0xFF; $hb++) {
169 for ($lb = 0x00; $lb <= 0xFF; $lb++) {
170 $items++ if $u2k_cp949{$hb*256 + $lb};
174 printf "static const unicode_char uni_to_cp949_tbl_%02x[] = {", $hb;
175 for ($lb = 0x00; $lb <= 0xFF; $lb++) {
176 $code = $hb*256 + $lb;
177 print ", " if ($items > 0);
178 print "\n " if ($items % $perline == 0);
179 $u2k_cp949{$code} = 0x003F unless $u2k_cp949{$code};
180 printf("0x%04X", $u2k_cp949{$code});
188 print "const unicode_char * uni_to_cp949_tbls[] = {\n";
189 for ($hb=0x00; $hb <= 0xFF; $hb++) {
190 print (($hb > 0x00) ?
",\n " : " ");
192 printf "uni_to_cp949_tbl_%02x", $hb;
202 print "#endif /* _KSX1001_HDR_ */\n";