1 
2 
3 static const unsigned short sjis_mac2wchar1[] = { // 0x03ac - 0x03c9
4 0x339c,	0x339f,	0x339d,	0x33a0,
5 0x33a4,	0xff4d,	0x33a1,	0x33a5,
6 0x339e,	0x33a2,	0x338e,	0xff47,
7 0x338f,	0x33c4,	0x3396,	0x3397,
8 0x2113,	0x3398,	0x33b3,	0x33b2,
9 0x33b1,	0x33b0,	0x2109,	0x33d4,
10 0x33cb,	0x3390,	0x3385,	0x3386,
11 0x3387,	0xf860,	};
12 static const unsigned short sjis_mac2wchar2[] = { // 0x0406 - 0x0420
13 0x2116,	0x33cd,
14 0x2121,	0xf861,	0x2664,	0x2667,
15 0x2661,	0x2662,	0x2660,	0x2663,
16 0x2665,	0x2666,	0x0000,	0x0000,
17 0x0000,	0x0000,	0x0000,	0x0000,
18 0x0000,	0x0000,	0x0000,	0x0000,
19 0x0000,	0x0000,	0x3020,	0x260e,
20 0x3004,	};
21 static const unsigned short sjis_mac2wchar3[] = { // 0x0432 - 0x0441
22 0x261e,	0x261c,
23 0x261d,	0x261f,	0x21c6,	0x21c4,
24 0x21c5,	0xf860,	0x21e8,	0x21e6,
25 0x21e7,	0x21e9,	0x21e8,	0x21e6,
26 0x21e7,	0x21e9,	};
27 static const unsigned short sjis_mac2wchar4[] = { // 0x0468 - 0x0480
28 0x3230,	0x322a,	0x322b,	0x322c,
29 0x322d,	0x322e,	0x322f,	0x3240,
30 0x3237,	0x3242,	0x3243,	0x3239,
31 0x323a,	0x3231,	0x323e,	0x3234,
32 0x3232,	0x323b,	0x3236,	0x3233,
33 0x3235,	0x323c,	0x323d,	0x323f,
34 0x3238,	};
35 static const unsigned short sjis_mac2wchar5[] = { // 0x04b8 - 0x04e8
36 0x5927,	0x5c0f,	0x32a4,	0x32a5,
37 0x32a6,	0x32a7,	0x32a8,	0x32a9,
38 0x3296,	0x329d,	0x3298,	0x329e,
39 0x63a7,	0x3299,	0x3349,	0x3322,
40 0x334d,	0x3314,	0x3316,	0x3305,
41 0x3333,	0x334e,	0x3303,	0x3336,
42 0x3318,	0x3315,	0x3327,	0x3351,
43 0x334a,	0x3339,	0x3357,	0x330d,
44 0x3342,	0x3323,	0x3326,	0x333b,
45 0x332b,	0x0000,	0x0000,	0x0000,
46 0x0000,	0x0000,	0x0000,	0x0000,
47 0x3300,	0x331e,	0x332a,	0x3331,
48 0x3347,	};
49 static const unsigned short sjis_mac2wchar6[] = { // 0x050c - 0x0551
50 0x337e,	0x337d,	0x337c,	0x337b,
51 0x0000,	0x0000,	0x0000,	0x0000,
52 0x0000,	0x0000,	0x0000,	0x0000,
53 0x0000,	0x0000,	0x0000,	0x0000,
54 0x0000,	0x0000,	0x0000,	0x0000,
55 0x0000,	0x337f,	0xf862,	0xf862,
56 0x222e,	0x221f,	0x22bf,	0x0000,
57 0x0000,	0x0000,	0x0000,	0x0000,
58 0x0000,	0x0000,	0x0000,	0x0000,
59 0x0000,	0x0000,	0x0000,	0x0000,
60 0x0000,	0x0000,	0x0000,	0x0000,
61 0x301d,	0x301f,	0x0000,	0x0000,
62 0x0000,	0x0000,	0x0000,	0x0000,
63 0x0000,	0x0000,	0x0000,	0x0000,
64 0x0000,	0x0000,	0x0000,	0x0000,
65 0x0000,	0x0000,	0x0000,	0x0000,
66 0x3094,	0x0000,	0x30f7,	0x30f8,
67 0x30f9,	0x30fa,	};
68 static const unsigned short sjis_mac2wchar7[] = { // 0x1ed9 - 0x1f18
69 0x3001,	0x3002,	0x0000,
70 0x0000,	0x0000,	0x0000,	0x0000,
71 0x0000,	0x0000,	0x0000,	0x0000,
72 0x0000,	0x0000,	0x0000,	0x0000,
73 0xffe3,	0xfe33,	0x0000,	0x0000,
74 0x0000,	0x0000,	0x0000,	0x0000,
75 0x0000,	0x0000,	0x0000,	0x30fc,
76 0xfe31,	0x2010,	0x0000,	0x0000,
77 0x301c,	0x2016,	0xff5c,	0x2026,
78 0xfe30,	0x0000,	0x0000,	0x0000,
79 0x0000,	0xfe35,	0xfe36,	0xfe39,
80 0xfe3a,	0xff3b,	0xff3d,	0xfe37,
81 0xfe38,	0xfe3f,	0xfe40,	0xfe3d,
82 0xfe3e,	0xfe41,	0xfe42,	0xfe43,
83 0xfe44,	0xfe3b,	0xfe3c,	0x0000,
84 0x0000,	0x0000,	0x0000,	0x0000,
85 0xff1d,	};
86 static const unsigned short sjis_mac2wchar8[] = { // 0x1ff2 - 0x20a5
87 0x3041,	0x0000,
88 0x3043,	0x0000,	0x3045,	0x0000,
89 0x3047,	0x0000,	0x3049,	0x0000,
90 0x0000,	0x0000,	0x0000,	0x0000,
91 0x0000,	0x0000,	0x0000,	0x0000,
92 0x0000,	0x0000,	0x0000,	0x0000,
93 0x0000,	0x0000,	0x0000,	0x0000,
94 0x0000,	0x0000,	0x0000,	0x0000,
95 0x0000,	0x0000,	0x0000,	0x0000,
96 0x3063,	0x0000,	0x0000,	0x0000,
97 0x0000,	0x0000,	0x0000,	0x0000,
98 0x0000,	0x0000,	0x0000,	0x0000,
99 0x0000,	0x0000,	0x0000,	0x0000,
100 0x0000,	0x0000,	0x0000,	0x0000,
101 0x0000,	0x0000,	0x0000,	0x0000,
102 0x0000,	0x0000,	0x0000,	0x0000,
103 0x0000,	0x0000,	0x0000,	0x0000,
104 0x3083,	0x0000,	0x3085,	0x0000,
105 0x3087,	0x0000,	0x0000,	0x0000,
106 0x0000,	0x0000,	0x0000,	0x308e,
107 0x0000,	0x0000,	0x0000,	0x0000,
108 0x0000,	0x0000,	0x0000,	0x0000,
109 0x0000,	0x0000,	0x0000,	0x0000,
110 0x0000,	0x0000,	0x0000,	0x0000,
111 0x30a1,	0x0000,	0x30a3,	0x0000,
112 0x30a5,	0x0000,	0x30a7,	0x0000,
113 0x30a9,	0x0000,	0x0000,	0x0000,
114 0x0000,	0x0000,	0x0000,	0x0000,
115 0x0000,	0x0000,	0x0000,	0x0000,
116 0x0000,	0x0000,	0x0000,	0x0000,
117 0x0000,	0x0000,	0x0000,	0x0000,
118 0x0000,	0x0000,	0x0000,	0x0000,
119 0x0000,	0x0000,	0x30c3,	0x0000,
120 0x0000,	0x0000,	0x0000,	0x0000,
121 0x0000,	0x0000,	0x0000,	0x0000,
122 0x0000,	0x0000,	0x0000,	0x0000,
123 0x0000,	0x0000,	0x0000,	0x0000,
124 0x0000,	0x0000,	0x0000,	0x0000,
125 0x0000,	0x0000,	0x0000,	0x0000,
126 0x0000,	0x0000,	0x0000,	0x0000,
127 0x0000,	0x0000,	0x30e3,	0x0000,
128 0x30e5,	0x0000,	0x30e7,	0x0000,
129 0x0000,	0x0000,	0x0000,	0x0000,
130 0x0000,	0x30ee,	0x0000,	0x0000,
131 0x0000,	0x0000,	0x0000,	0x0000,
132 0x30f5,	0x30f6,	};
133 
134 static const unsigned short wchar2sjis_mac4[] = { // 0x2660 - 0x2667
135 0x040e,	0x040c,	0x040d,	0x040f,
136 0x040a,	0x0410,	0x0411,	0x040b,
137 };
138 
139 static const unsigned short wchar2sjis_mac7[] = { // 0x322a - 0x3243
140 0x0469, 0x046a,
141 0x046b, 0x046c, 0x046d, 0x046e,
142 0x0468, 0x0475, 0x0478, 0x047b,
143 0x0477, 0x047c, 0x047a, 0x0470,
144 0x0480, 0x0473, 0x0474, 0x0479,
145 0x047d, 0x047e, 0x0476, 0x047f,
146 0x046f, 0x0000, 0x0471, 0x0472,
147 };
148 
149 static const unsigned short wchar2sjis_mac8[] = { // 0x3296 - 0x329e
150 0x04c0, 0x0000,
151 0x04c2, 0x04c5, 0x0000, 0x0000,
152 0x0000, 0x04c1, 0x04c3, };
153 
154 static const unsigned short wchar2sjis_mac9[] = { // 0x3300 - 0x33d4
155 0x04e4,	0x0000,	0x0000,	0x04ce,
156 0x0000,	0x04cb,	0x0000,	0x0000,
157 0x0000,	0x0000,	0x0000,	0x0000,
158 0x0000,	0x04d7,	0x0000,	0x0000,
159 0x0000,	0x0000,	0x0000,	0x0000,
160 0x04c9,	0x04d1,	0x04ca,	0x0000,
161 0x04d0,	0x0000,	0x0000,	0x0000,
162 0x0000,	0x0000,	0x04e5,	0x0000,
163 0x0000,	0x0000,	0x04c7,	0x04d9,
164 0x0000,	0x0000,	0x04da,	0x04d2,
165 0x0000,	0x0000,	0x04e6,	0x04dc,
166 0x0000,	0x0000,	0x0000,	0x0000,
167 0x0000,	0x04e7,	0x0000,	0x04cc,
168 0x0000,	0x0000,	0x04cf,	0x0000,
169 0x0000,	0x04d5,	0x0000,	0x04db,
170 0x0000,	0x0000,	0x0000,	0x0000,
171 0x0000,	0x0000,	0x04d8,	0x0000,
172 0x0000,	0x0000,	0x0000,	0x04e8,
173 0x0000,	0x04c6,	0x04d4,	0x0000,
174 0x0000,	0x04c8,	0x04cd,	0x0000,
175 0x0000,	0x04d3,	0x0000,	0x0000,
176 0x0000,	0x0000,	0x0000,	0x04d6,
177 0x0000,	0x0000,	0x0000,	0x0000,
178 0x0000,	0x0000,	0x0000,	0x0000,
179 0x0000,	0x0000,	0x0000,	0x0000,
180 0x0000,	0x0000,	0x0000,	0x0000,
181 0x0000,	0x0000,	0x0000,	0x0000,
182 0x0000,	0x0000,	0x0000,	0x0000,
183 0x0000,	0x0000,	0x0000,	0x0000,
184 0x0000,	0x0000,	0x0000,	0x0000,
185 0x0000,	0x0000,	0x0000,	0x050f,
186 0x050e,	0x050d,	0x050c,	0x0521,
187 0x0000,	0x0000,	0x0000,	0x0000,
188 0x0000,	0x03c6,	0x03c7,	0x03c8,
189 0x0000,	0x0000,	0x0000,	0x0000,
190 0x0000,	0x0000,	0x03b6,	0x03b8,
191 0x03c5,	0x0000,	0x0000,	0x0000,
192 0x0000,	0x0000,	0x03ba,	0x03bb,
193 0x03bd,	0x0000,	0x0000,	0x0000,
194 0x03ac,	0x03ae,	0x03b4,	0x03ad,
195 0x03af,	0x03b2,	0x03b5,	0x0000,
196 0x03b0,	0x03b3,	0x0000,	0x0000,
197 0x0000,	0x0000,	0x0000,	0x0000,
198 0x0000,	0x0000,	0x0000,	0x0000,
199 0x03c1,	0x03c0,	0x03bf,	0x03be,
200 0x0000,	0x0000,	0x0000,	0x0000,
201 0x0000,	0x0000,	0x0000,	0x0000,
202 0x0000,	0x0000,	0x0000,	0x0000,
203 0x0000,	0x0000,	0x0000,	0x0000,
204 0x03b9,	0x0000,	0x0000,	0x0000,
205 0x0000,	0x0000,	0x0000,	0x03c4,
206 0x0000,	0x0407,	0x0000,	0x0000,
207 0x0000,	0x0000,	0x0000,	0x0000,
208 0x03c3,	};
209 
210 static const unsigned short wchar2sjis_mac10[] = { // 0xfe30 - 0xfe44
211 0x1efc,	0x1ef4,	0x0000,	0x1ee9,
212 0x0000,	0x1f01,	0x1f02,	0x1f07,
213 0x1f08,	0x1f03,	0x1f04,	0x1f11,
214 0x1f12,	0x1f0b,	0x1f0c,	0x1f09,
215 0x1f0a,	0x1f0d,	0x1f0e,	0x1f0f,
216 0x1f10,	};
217 
218 static const unsigned short code_tbl[][3] = {
219 	{0x02f0, 0x0303, 0x2460},
220 	{0x030e, 0x0321, 0x2474},
221 	{0x032c, 0x0334, 0x2776},
222 	{0x0341, 0x0349, 0x2488},
223 	{0x034e, 0x0359, 0x2160},
224 	{0x0362, 0x036d, 0x2170},
225 	{0x038a, 0x03a3, 0x249c},
226 };
227 
228 static const unsigned short code_ofst_tbl[] [2]= {
229 	{0x03ac, 0x03c9},
230 	{0x0406, 0x0420},
231 	{0x0432, 0x0441},
232 	{0x0468, 0x0480},
233 	{0x04b8, 0x04e8},
234 	{0x050c, 0x0551},
235 	{0x1ed9, 0x1f18},
236 	{0x1ff2, 0x20a5},
237 };
238 
239 static const unsigned short *code_map[] = {
240 	sjis_mac2wchar1, sjis_mac2wchar2, sjis_mac2wchar3, sjis_mac2wchar4,
241 	sjis_mac2wchar5, sjis_mac2wchar6, sjis_mac2wchar7, sjis_mac2wchar8};
242 
243 static const unsigned short code_tbl_m[][6] = {
244 	{0x0340, 0xf860, 0x0030, 0x002e, 0x0000, 0x0000},
245 	{0x03c9, 0xf860, 0x0054, 0x0042, 0x0000, 0x0000},
246 	{0x035c, 0xf860, 0x0058, 0x0056, 0x0000, 0x0000},
247 	{0x0370, 0xf860, 0x0078, 0x0076, 0x0000, 0x0000},
248 	{0x0439, 0xf860, 0x2193, 0x2191, 0x0000, 0x0000},
249 	{0x0409, 0xf861, 0x0046, 0x0041, 0x0058, 0x0000},
250 	{0x035b, 0xf861, 0x0058, 0x0049, 0x0056, 0x0000},
251 	{0x036f, 0xf861, 0x0078, 0x0069, 0x0076, 0x0000},
252 	{0x035a, 0xf862, 0x0058, 0x0049, 0x0049, 0x0049},
253 	{0x036e, 0xf862, 0x0078, 0x0069, 0x0069, 0x0069},
254 	{0x0522, 0xf862, 0x6709, 0x9650, 0x4f1a, 0x793e},
255 	{0x0523, 0xf862, 0x8ca1, 0x56e3, 0x6cd5, 0x4eba},
256 };
257 
258 static  int code_tbl_m_len = sizeof(code_tbl_m)/(sizeof(unsigned short)*6);
259 
260 static const unsigned short s_form_tbl[] = {
261 	0x2010,0x2016,0x2026,
262 	0x3001,0x3002,0x301c,0x3041,0x3043,0x3045,0x3047,0x3049,
263 	0x3063,0x3083,0x3085,0x3087,0x308e,0x30a1,0x30a3,0x30a5,
264 	0x30a7,0x30a9,0x30c3,0x30e3,0x30e5,0x30e7,0x30ee,0x30f5,
265 	0x30f6,0x30fc,0xff1d,0xff3b,0xff3d,0xff5c,0xffe3, // vertical f87e (34)
266 	0x2026,0xff47,0xff4d, // halfwidth f87f (3)
267 	0x5927,0x5c0f,0x63a7, // enclosing circle 20dd (3)
268 	0x21e6,0x21e7,0x21e8,0x21e9, // black arrow f87a (4)
269 };
270 
271 static int s_form_tbl_len = sizeof(s_form_tbl)/sizeof(unsigned short);
272 
273 static const unsigned short s_form_sjis_tbl[] = {
274 	0xeb5d,0xeb61,0xeb63,
275 	0xeb41,0xeb42,0xeb60,0xec9f,0xeca1,0xeca3,0xeca5,0xeca7,
276 	0xecc1,0xece1,0xece3,0xece5,0xecec,0xed40,0xed42,0xed44,
277 	0xed46,0xed48,0xed62,0xed83,0xed85,0xed87,0xed8e,0xed95,
278 	0xed96,0xeb5b,0xeb81,0xeb6d,0xeb6e,0xeb62,0xeb50, // vertical
279 	0x00ff,0x864b,0x8645, // halfwidth
280 	0x8791,0x8792,0x879d, // enclosing circle
281 	0x86d4,0x86d5,0x86d3,0x86d6, // black arrow
282 };
283 
284 static const unsigned short s_form_sjis_fallback_tbl[] = {
285 	0x815d,0x8161,0x8163,
286 	0x8141,0x8142,0x8160,0x829f,0x82a1,0x82a3,0x82a5,0x82a7,
287 	0x82c1,0x82e1,0x82e3,0x82e5,0x82ec,0x8340,0x8342,0x8344,
288 	0x8346,0x8348,0x8362,0x8383,0x8385,0x8387,0x838e,0x8395,
289 	0x8396,0x815b,0x8181,0x816d,0x816e,0x8162,0x8150, // vertical
290 	0x815d,0x8287,0x828d, // halfwidth
291 	0x91e5,0x8fac,0x8d54, // enclosing circle
292 	0x86d0,0x86d1,0x86cf,0x86d2, // arrow
293 };
294 
295 static const unsigned short wchar2sjis_mac_r_tbl[][3] = {
296 	{0x2160, 0x216b, 0x034e},
297 	{0x2170, 0x217b, 0x0362},
298 	{0x2460, 0x2473, 0x02f0},
299 	{0x2474, 0x2487, 0x030e},
300 	{0x2488, 0x2490, 0x0341},
301 	{0x249c, 0x24b5, 0x038a},
302 	{0x2776, 0x277e, 0x032c},
303 	{0x30f7, 0x30fa, 0x054e},
304 	{0x32a4, 0x32a9, 0x04ba},
305 };
306 
307 static int wchar2sjis_mac_r_tbl_len = sizeof(wchar2sjis_mac_r_tbl)/(3*sizeof(unsigned short));
308 
309 static const unsigned short wchar2sjis_mac_r_map[][2] = {
310 	{0x2660, 0x2667},
311 	{0x322a, 0x3243},
312 	{0x3296, 0x329e},
313 	{0x3300, 0x33d4},
314 	{0xfe30, 0xfe44},
315 };
316 
317 static int wchar2sjis_mac_r_map_len = sizeof(wchar2sjis_mac_r_map)/(2*sizeof(unsigned short));
318 
319 static const unsigned short *wchar2sjis_mac_code_map[] = {
320 	wchar2sjis_mac4, wchar2sjis_mac7, wchar2sjis_mac8, wchar2sjis_mac9, wchar2sjis_mac10};
321 
322 static const unsigned short wchar2sjis_mac_wchar_tbl[][2] = {
323 	{0x2109, 0x03c2},
324 	{0x2113, 0x03bc},
325 	{0x2116, 0x0406},
326 	{0x2121, 0x0408},
327 	{0x21c4, 0x0437},
328 	{0x21c5, 0x0438},
329 	{0x21c6, 0x0436},
330 	{0x21e6, 0x043b},
331 	{0x21e7, 0x043c},
332 	{0x21e8, 0x043a},
333 	{0x21e9, 0x043d},
334 	{0x221f, 0x0525},
335 	{0x222e, 0x0524},
336 	{0x22bf, 0x0526},
337 	{0x260e, 0x041f},
338 	{0x261c, 0x0433},
339 	{0x261d, 0x0434},
340 	{0x261e, 0x0432},
341 	{0x261f, 0x0435},
342 	{0x3004, 0x0420},
343 	{0x301d, 0x0538},
344 	{0x301f, 0x0539},
345 	{0x3020, 0x041e},
346 	{0x3094, 0x054c},
347 };
348 
349 static int wchar2sjis_mac_wchar_tbl_len = sizeof(wchar2sjis_mac_wchar_tbl)/(2*sizeof(unsigned short));
350