Annotation of embedaddon/libiconv/lib/cp50221_0212_ext.h, revision 1.1.1.1
1.1 misho 1: /*
2: * Copyright (C) 1999-2011, 2016 Free Software Foundation, Inc.
3: * This file is part of the GNU LIBICONV Library.
4: *
5: * The GNU LIBICONV Library is free software; you can redistribute it
6: * and/or modify it under the terms of the GNU Library General Public
7: * License as published by the Free Software Foundation; either version 2
8: * of the License, or (at your option) any later version.
9: *
10: * The GNU LIBICONV Library is distributed in the hope that it will be
11: * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Library General Public License for more details.
14: *
15: * You should have received a copy of the GNU Library General Public
16: * License along with the GNU LIBICONV Library; see the file COPYING.LIB.
17: * If not, see <https://www.gnu.org/licenses/>.
18: */
19:
20: /*
21: * CP50221 JISX0212 extensions
22: */
23:
24: static const unsigned short cp50221_0212_ext_2uni[112] = {
25: /* 0x00 */
26: 0xfffd, 0x2170, 0x2171, 0x2172, 0x2173, 0x2174, 0x2175, 0x2176,
27: 0x2177, 0x2178, 0x2179, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
28: /* 0x10 */
29: 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xff07, 0xff02, 0xfffd,
30: 0xfffd, 0xfffd, 0x70bb, 0x4efc, 0x50f4, 0x51ec, 0x5307, 0x5324,
31: /* 0x20 */
32: 0xfa0e, 0x548a, 0x5759, 0xfa0f, 0xfa10, 0x589e, 0x5bec, 0x5cf5,
33: 0x5d53, 0xfa11, 0x5fb7, 0x6085, 0x6120, 0x654e, 0xfffd, 0x6665,
34: /* 0x30 */
35: 0xfa12, 0xf929, 0x6801, 0xfa13, 0xfa14, 0x6a6b, 0x6ae2, 0x6df8,
36: 0x6df2, 0x7028, 0xfa15, 0xfa16, 0x7501, 0x7682, 0x769e, 0xfa17,
37: /* 0x40 */
38: 0x7930, 0xfa18, 0xfa19, 0xfa1a, 0xfa1b, 0x7ae7, 0xfa1c, 0xfa1d,
39: 0x7da0, 0x7dd6, 0xfa1e, 0x8362, 0xfa1f, 0x85b0, 0xfa20, 0xfa21,
40: /* 0x50 */
41: 0x8807, 0xfa22, 0x8b7f, 0x8cf4, 0x8d76, 0xfa23, 0xfa24, 0xfa25,
42: 0x90de, 0xfa26, 0x9115, 0xfa27, 0xfa28, 0x9592, 0xf9dc, 0xfa29,
43: /* 0x60 */
44: 0x973b, 0xfffd, 0x9751, 0xfa2a, 0xfa2b, 0xfa2c, 0x999e, 0x9ad9,
45: 0x9b72, 0xfa2d, 0x9ed1, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
46: };
47:
48: static int
49: cp50221_0212_ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
50: {
51: unsigned char c = *s;
52: if (c < 0x70) {
53: unsigned short wc = cp50221_0212_ext_2uni[c];
54: if (wc != 0xfffd) {
55: *pwc = (ucs4_t) wc;
56: return 1;
57: }
58: }
59: else if (c == 0xa1) {
60: *pwc = 0x974d;
61: return 1;
62: }
63: return RET_ILSEQ;
64: }
65:
66: static const unsigned char cp50221_0212_ext_page21[16] = {
67: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, /* 0x70-0x77 */
68: 0x09, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */
69: };
70: static const unsigned char cp50221_0212_ext_page53[40] = {
71: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, /* 0x00-0x07 */
72: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */
73: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */
74: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
75: 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, /* 0x20-0x27 */
76: };
77: static const unsigned char cp50221_0212_ext_page6d[16] = {
78: 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf0-0xf7 */
79: 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf8-0xff */
80: };
81: static const unsigned char cp50221_0212_ext_page76[32] = {
82: 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
83: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
84: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
85: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, /* 0x98-0x9f */
86: };
87: static const unsigned char cp50221_0212_ext_page7d[56] = {
88: 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */
89: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */
90: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */
91: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
92: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
93: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
94: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x00, /* 0xd0-0xd7 */
95: };
96: static const unsigned char cp50221_0212_ext_page97[32] = {
97: 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
98: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */
99: 0x00, 0x00, 0x00, 0x00, 0x00, 0xa1, 0x00, 0x00, /* 0x48-0x4f */
100: 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
101: };
102: static const unsigned char cp50221_0212_ext_pagefa[40] = {
103: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x23, /* 0x08-0x0f */
104: 0x24, 0x29, 0x30, 0x33, 0x34, 0x3a, 0x3b, 0x3f, /* 0x10-0x17 */
105: 0x41, 0x42, 0x43, 0x44, 0x46, 0x47, 0x4a, 0x4c, /* 0x18-0x1f */
106: 0x4e, 0x4f, 0x51, 0x55, 0x56, 0x57, 0x59, 0x5b, /* 0x20-0x27 */
107: 0x5c, 0x5f, 0x63, 0x64, 0x65, 0x69, 0x00, 0x00, /* 0x28-0x2f */
108: };
109: static const unsigned char cp50221_0212_ext_pageff[8] = {
110: 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x15, /* 0x00-0x07 */
111: };
112:
113: static int
114: cp50221_0212_ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
115: {
116: unsigned char c = 0;
117: if (wc >= 0x2170 && wc < 0x2180)
118: c = cp50221_0212_ext_page21[wc-0x2170];
119: else if (wc == 0x4efc)
120: c = 0x1b;
121: else if (wc == 0x50f4)
122: c = 0x1c;
123: else if (wc == 0x51ec)
124: c = 0x1d;
125: else if (wc >= 0x5300 && wc < 0x5328)
126: c = cp50221_0212_ext_page53[wc-0x5300];
127: else if (wc == 0x548a)
128: c = 0x21;
129: else if (wc == 0x5759)
130: c = 0x22;
131: else if (wc == 0x589e)
132: c = 0x25;
133: else if (wc == 0x5bec)
134: c = 0x26;
135: else if (wc == 0x5cf5)
136: c = 0x27;
137: else if (wc == 0x5d53)
138: c = 0x28;
139: else if (wc == 0x5fb7)
140: c = 0x2a;
141: else if (wc == 0x6085)
142: c = 0x2b;
143: else if (wc == 0x6120)
144: c = 0x2c;
145: else if (wc == 0x654e)
146: c = 0x2d;
147: else if (wc == 0x6665)
148: c = 0x2f;
149: else if (wc == 0x6801)
150: c = 0x32;
151: else if (wc == 0x6a6b)
152: c = 0x35;
153: else if (wc == 0x6ae2)
154: c = 0x36;
155: else if (wc >= 0x6df0 && wc < 0x6e00)
156: c = cp50221_0212_ext_page6d[wc-0x6df0];
157: else if (wc == 0x7028)
158: c = 0x39;
159: else if (wc == 0x70bb)
160: c = 0x1a;
161: else if (wc == 0x7501)
162: c = 0x3c;
163: else if (wc >= 0x7680 && wc < 0x76a0)
164: c = cp50221_0212_ext_page76[wc-0x7680];
165: else if (wc == 0x7930)
166: c = 0x40;
167: else if (wc == 0x7ae7)
168: c = 0x45;
169: else if (wc >= 0x7da0 && wc < 0x7dd8)
170: c = cp50221_0212_ext_page7d[wc-0x7da0];
171: else if (wc == 0x8362)
172: c = 0x4b;
173: else if (wc == 0x85b0)
174: c = 0x4d;
175: else if (wc == 0x8807)
176: c = 0x50;
177: else if (wc == 0x8b7f)
178: c = 0x52;
179: else if (wc == 0x8cf4)
180: c = 0x53;
181: else if (wc == 0x8d76)
182: c = 0x54;
183: else if (wc == 0x90de)
184: c = 0x58;
185: else if (wc == 0x9115)
186: c = 0x5a;
187: else if (wc == 0x9592)
188: c = 0x5d;
189: else if (wc >= 0x9738 && wc < 0x9758)
190: c = cp50221_0212_ext_page97[wc-0x9738];
191: else if (wc == 0x999e)
192: c = 0x66;
193: else if (wc == 0x9ad9)
194: c = 0x67;
195: else if (wc == 0x9b72)
196: c = 0x68;
197: else if (wc == 0x9ed1)
198: c = 0x6a;
199: else if (wc == 0xf929)
200: c = 0x31;
201: else if (wc == 0xf9dc)
202: c = 0x5e;
203: else if (wc >= 0xfa08 && wc < 0xfa30)
204: c = cp50221_0212_ext_pagefa[wc-0xfa08];
205: else if (wc >= 0xff00 && wc < 0xff08)
206: c = cp50221_0212_ext_pageff[wc-0xff00];
207: if (c != 0) {
208: *r = c;
209: return 1;
210: }
211: return RET_ILUNI;
212: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>