Mercurial > emacs
annotate admin/charsets/cp932.awk @ 94790:fa41f74280f5
Switch to recommended form of GPLv3 permissions notice.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Fri, 09 May 2008 04:44:29 +0000 |
parents | 9a10da450c13 |
children | eb2d9dfc8486 |
rev | line source |
---|---|
89786
cce22763e5b1
Append user defined area of CP932.
Kenichi Handa <handa@m17n.org>
parents:
89745
diff
changeset
|
1 # cp932.awk -- Add sort keys and append user defined area to CP932-2BYTE.map. |
91414
9a10da450c13
Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents:
89916
diff
changeset
|
2 # Copyright (C) 2004, 2005, 2006, 2007, 2008 |
89745 | 3 # National Institute of Advanced Industrial Science and Technology (AIST) |
4 # Registration Number H13PRO009 | |
5 # | |
6 # This file is part of GNU Emacs. | |
7 # | |
8 # GNU Emacs is free software; you can redistribute it and/or modify | |
9 # it under the terms of the GNU General Public License as published by | |
91414
9a10da450c13
Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents:
89916
diff
changeset
|
10 # the Free Software Foundation; either version 3, or (at your option) |
89745 | 11 # any later version. |
12 # | |
13 # GNU Emacs is distributed in the hope that it will be useful, | |
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 # GNU General Public License for more details. | |
17 # | |
18 # You should have received a copy of the GNU General Public License | |
19 # along with GNU Emacs; see the file COPYING. If not, write to the | |
91414
9a10da450c13
Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents:
89916
diff
changeset
|
20 # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
9a10da450c13
Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents:
89916
diff
changeset
|
21 # Boston, MA 02110-1301, USA. |
89745 | 22 |
23 # Comment: | |
24 # Add a sort key 0, 1, 2, or 3 at the tail of each line as a comment | |
25 # to realize the round trip mapping to Unicode works as described in | |
26 # this page: | |
27 # http://support.microsoft.com/default.aspx?scid=kb;EN-US;170559 | |
28 # Each sort key means as below: | |
29 # 0: JISX0208 characters. | |
30 # 1: NEC special characters. | |
31 # 2: IBM extension characters. | |
32 # 3: NEC selection of IBM extension characters. | |
89786
cce22763e5b1
Append user defined area of CP932.
Kenichi Handa <handa@m17n.org>
parents:
89745
diff
changeset
|
33 # 4: user defined area |
89745 | 34 |
35 BEGIN { | |
36 tohex["A"] = 10; | |
37 tohex["B"] = 11; | |
38 tohex["C"] = 12; | |
39 tohex["D"] = 13; | |
40 tohex["E"] = 14; | |
41 tohex["F"] = 15; | |
42 } | |
43 | |
44 function decode_hex(str) { | |
45 n = 0; | |
46 len = length(str); | |
47 for (i = 1; i <= len; i++) | |
48 { | |
49 c = substr(str, i, 1); | |
50 if (c >= "0" && c <= "9") | |
51 n = n * 16 + (c - "0"); | |
52 else | |
53 n = n * 16 + tohex[c]; | |
54 } | |
55 return n; | |
56 } | |
57 | |
58 function sjis_to_jis_ku(code) | |
59 { | |
60 s1 = int(code / 256); | |
61 s2 = code % 256; | |
62 if (s2 >= 159) # s2 >= 0x9F | |
63 { | |
64 if (s1 >= 224) # s1 >= 0xE0 | |
65 j1 = s1 * 2 - 352; # j1 = s1 * 2 - 0x160 | |
66 else | |
67 j1 = s1 * 2 - 224; # j1 = s1 * 2 - 0xE0 | |
89786
cce22763e5b1
Append user defined area of CP932.
Kenichi Handa <handa@m17n.org>
parents:
89745
diff
changeset
|
68 j2 = s2 - 126 # j2 = s2 - #x7E |
89745 | 69 } |
70 else | |
71 { | |
72 if (s1 >= 224) | |
73 j1 = s1 * 2 - 353; # j1 = s1 * 2 - 0x161 | |
74 else | |
75 j1 = s1 * 2 - 225; # j1 = s1 * 2 - 0xE1 | |
89786
cce22763e5b1
Append user defined area of CP932.
Kenichi Handa <handa@m17n.org>
parents:
89745
diff
changeset
|
76 if (s2 >= 127) # s2 >= #x7F |
cce22763e5b1
Append user defined area of CP932.
Kenichi Handa <handa@m17n.org>
parents:
89745
diff
changeset
|
77 j2 = s2 - 32; |
cce22763e5b1
Append user defined area of CP932.
Kenichi Handa <handa@m17n.org>
parents:
89745
diff
changeset
|
78 else |
cce22763e5b1
Append user defined area of CP932.
Kenichi Handa <handa@m17n.org>
parents:
89745
diff
changeset
|
79 j2 = s2 - 31; |
89745 | 80 } |
81 return j1 - 32; | |
82 } | |
83 | |
84 /^0x[89E]/ { | |
85 sjis=decode_hex(substr($1, 3, 4)) | |
86 ku=sjis_to_jis_ku(sjis); | |
87 if (ku == 13) | |
89786
cce22763e5b1
Append user defined area of CP932.
Kenichi Handa <handa@m17n.org>
parents:
89745
diff
changeset
|
88 printf "%s # 1 %02X%02X\n", $0, j1, j2; |
89745 | 89 else if (ku >= 89 && ku <= 92) |
89786
cce22763e5b1
Append user defined area of CP932.
Kenichi Handa <handa@m17n.org>
parents:
89745
diff
changeset
|
90 printf "%s # 3 %02X%02X\n", $0, j1, j2; |
89745 | 91 else |
89786
cce22763e5b1
Append user defined area of CP932.
Kenichi Handa <handa@m17n.org>
parents:
89745
diff
changeset
|
92 printf "%s # 0 %02X%02X\n", $0, j1, j2; |
89745 | 93 next; |
94 } | |
95 | |
96 /^0xF/ { | |
89786
cce22763e5b1
Append user defined area of CP932.
Kenichi Handa <handa@m17n.org>
parents:
89745
diff
changeset
|
97 printf "%s # 2\n", $0; |
89745 | 98 next; |
99 } | |
100 | |
101 { | |
102 print; | |
103 } | |
89786
cce22763e5b1
Append user defined area of CP932.
Kenichi Handa <handa@m17n.org>
parents:
89745
diff
changeset
|
104 |
cce22763e5b1
Append user defined area of CP932.
Kenichi Handa <handa@m17n.org>
parents:
89745
diff
changeset
|
105 END { |
cce22763e5b1
Append user defined area of CP932.
Kenichi Handa <handa@m17n.org>
parents:
89745
diff
changeset
|
106 code = 57344; # 0xE000 |
cce22763e5b1
Append user defined area of CP932.
Kenichi Handa <handa@m17n.org>
parents:
89745
diff
changeset
|
107 for (i = 240; i < 250; i++) |
cce22763e5b1
Append user defined area of CP932.
Kenichi Handa <handa@m17n.org>
parents:
89745
diff
changeset
|
108 { |
cce22763e5b1
Append user defined area of CP932.
Kenichi Handa <handa@m17n.org>
parents:
89745
diff
changeset
|
109 for (j = 64; j <= 126; j++) |
cce22763e5b1
Append user defined area of CP932.
Kenichi Handa <handa@m17n.org>
parents:
89745
diff
changeset
|
110 printf "0x%02X%02X 0x%04X # 4\n", i, j, code++; |
cce22763e5b1
Append user defined area of CP932.
Kenichi Handa <handa@m17n.org>
parents:
89745
diff
changeset
|
111 for (j = 128; j <= 158; j++) |
cce22763e5b1
Append user defined area of CP932.
Kenichi Handa <handa@m17n.org>
parents:
89745
diff
changeset
|
112 printf "0x%02X%02X 0x%04X # 4\n", i, j, code++; |
cce22763e5b1
Append user defined area of CP932.
Kenichi Handa <handa@m17n.org>
parents:
89745
diff
changeset
|
113 for (; j <= 252; j++) |
cce22763e5b1
Append user defined area of CP932.
Kenichi Handa <handa@m17n.org>
parents:
89745
diff
changeset
|
114 printf "0x%02X%02X 0x%04X # 4\n", i, j, code++; |
cce22763e5b1
Append user defined area of CP932.
Kenichi Handa <handa@m17n.org>
parents:
89745
diff
changeset
|
115 } |
cce22763e5b1
Append user defined area of CP932.
Kenichi Handa <handa@m17n.org>
parents:
89745
diff
changeset
|
116 } |
89916
e0e4e6a0599f
Changes from arch/CVS synchronization
Miles Bader <miles@gnu.org>
parents:
89786
diff
changeset
|
117 |
e0e4e6a0599f
Changes from arch/CVS synchronization
Miles Bader <miles@gnu.org>
parents:
89786
diff
changeset
|
118 # arch-tag: 998dc444-759d-43ef-87e3-2ab205011394 |