annotate admin/charsets/cp932.awk @ 97802:48c669cb45f9

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