1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
|
/* "$Id: $"
*
* Author: Jean-Marc Lienher ( http://oksid.ch )
* Copyright 2000-2003 by O'ksi'D.
*
* This library is free software. Distribution and use rights are outlined in
* the file "COPYING" which should have been included with this file. If this
* file is missing or damaged, see the license at:
*
* http://www.fltk.org/COPYING.php
*
* Please report all bugs and problems on the following page:
*
* http://www.fltk.org/str.php
*/
#include <stdlib.h>
#include <string.h>
#define RET_ILSEQ -1
#define RET_TOOFEW(x) (-10 - x)
#define RET_TOOSMALL -2
#define conv_t void*
#define ucs4_t unsigned int
typedef struct {
unsigned short indx;
unsigned short used;
} Summary16;
#define NEED_TOMB /* indicates what part of these include files is needed here (avoid compilation warnings) */
#include "lcUniConv/cp936ext.h"
#include "lcUniConv/big5.h"
#include "lcUniConv/gb2312.h"
#include "lcUniConv/iso8859_10.h"
#include "lcUniConv/iso8859_11.h"
#include "lcUniConv/iso8859_13.h"
#include "lcUniConv/iso8859_14.h"
#include "lcUniConv/iso8859_15.h"
#include "lcUniConv/iso8859_2.h"
#include "lcUniConv/iso8859_3.h"
#include "lcUniConv/iso8859_4.h"
#include "lcUniConv/iso8859_5.h"
#include "lcUniConv/iso8859_6.h"
#include "lcUniConv/iso8859_7.h"
#include "lcUniConv/iso8859_8.h"
#include "lcUniConv/iso8859_9.h"
#include "lcUniConv/jisx0201.h"
#include "lcUniConv/jisx0208.h"
#include "lcUniConv/jisx0212.h"
#include "lcUniConv/koi8_r.h"
#include "lcUniConv/koi8_u.h"
#include "lcUniConv/ksc5601.h"
#include "lcUniConv/cp1251.h"
#include "headers/symbol_.h"
#include "headers/dingbats_.h"
/*************** conv_gen.c ************/
/*const*/
int ucs2fontmap(char *s, unsigned int ucs, int enc) {
switch(enc) {
case 0: /* iso10646-1 */
s[0] = (char) ((ucs & 0xFF00) >> 8);
s[1] = (char) (ucs & 0xFF);
return 0;
case 1: /* iso8859-1 */
if (ucs <= 0x00FF) {
if (ucs >= 0x0001) {
s[0] = 0;
s[1] = (char) (ucs & 0xFF);
return 1;
}
}
break;
case 2: /* iso8859-2 */
if (ucs <= 0x00a0) {
s[0] = 0;
s[1] = (char) ucs;
return 2;
} else if (ucs < 0x0180) {
if (ucs >= 0x00a0) {
s[0] = 0;
s[1] = (char) iso8859_2_page00[ucs-0x00a0];
if (s[1]) return 2;
}
} else if (ucs < 0x02e0) {
if (ucs >= 0x02c0) {
s[0] = 0;
s[1] = (char) iso8859_2_page02[ucs-0x02c0];
if (s[1]) return 2;
}
}
break;
case 3: /* iso8859-3 */
if (iso8859_3_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
return 3;
}
break;
case 4: /* iso8859-4 */
if (iso8859_4_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
return 4;
}
break;
case 5: /* iso8859-5 */
if (iso8859_5_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
return 5;
}
break;
case 6: /* iso8859-6 */
if (iso8859_6_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
return 6;
}
break;
case 7: /* iso8859-7 */
if (iso8859_7_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
return 7;
}
break;
case 8: /* iso8859-8 */
if (iso8859_8_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
return 8;
}
break;
case 9: /* iso8859-9 */
if (iso8859_9_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
return 9;
}
break;
case 10: /* iso8859-10 */
if (iso8859_10_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
return 10;
}
break;
case 25: /* iso8859-11 */
if (iso8859_11_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
return 25;
}
break;
case 11: /* iso8859-13 */
if (iso8859_13_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
return 11;
}
break;
case 12: /* iso8859-14 */
if (iso8859_14_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
return 12;
}
break;
case 13: /* iso8859-15 */
if (iso8859_15_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
return 13;
}
break;
case 14: /* koi8-r */
if (koi8_r_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
return 14;
}
break;
case 15: /* big5 */
if (big5_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
return 15;
}
break;
case 16: /* ksc5601.1987-0 */
if (ksc5601_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
return 16;
}
break;
case 17: /* gb2312.1980-0 */
if (gb2312_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
return 17;
}
break;
case 18: /* jisx0201.1976-0 */
if (jisx0201_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
return 18;
}
break;
case 19: /* jisx0208.1983-0 */
if (jisx0208_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
return 19;
}
break;
case 20: /* jisx0212.1990-0 */
if (jisx0212_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
return 20;
}
break;
case 21: /* symbol */
if (ucs <= 0x00F7) {
if (ucs >= 0x0020) {
s[0] = 0;
s[1] = unicode_to_symbol_1b_0020[ucs - 0x0020];
if (s[1]) return 21;
}
} else if (ucs <= 0x0192) {
if (ucs >= 0x0192) {
s[0] = 0;
s[1] = unicode_to_symbol_1b_0192[ucs - 0x0192];
if (s[1]) return 21;
}
} else if (ucs <= 0x03D6) {
if (ucs >= 0x0391) {
s[0] = 0;
s[1] = unicode_to_symbol_1b_0391[ucs - 0x0391];
if (s[1]) return 21;
}
} else if (ucs <= 0x232A) {
if (ucs >= 0x2022) {
s[0] = 0;
s[1] = unicode_to_symbol_1b_2022[ucs - 0x2022];
if (s[1]) return 21;
}
} else if (ucs <= 0x25CA) {
if (ucs >= 0x25CA) {
s[0] = 0;
s[1] = unicode_to_symbol_1b_25CA[ucs - 0x25CA];
if (s[1]) return 21;
}
} else if (ucs <= 0x2666) {
if (ucs >= 0x2660) {
s[0] = 0;
s[1] = unicode_to_symbol_1b_2660[ucs - 0x2660];
if (s[1]) return 21;
}
} else if (ucs <= 0xF6DB) {
if (ucs >= 0xF6D9) {
s[0] = 0;
s[1] = unicode_to_symbol_1b_F6D9[ucs - 0xF6D9];
if (s[1]) return 21;
}
} else if (ucs <= 0xF8FE) {
if (ucs >= 0xF8E5) {
s[0] = 0;
s[1] = unicode_to_symbol_1b_F8E5[ucs - 0xF8E5];
if (s[1]) return 21;
}
}
break;
case 22: /* dingbats */
if (ucs <= 0x00A0) {
if (ucs >= 0x0020) {
s[0] = 0;
s[1] = unicode_to_dingbats_1b_0020[ucs - 0x0020];
if (s[1]) return 22;
}
} else if (ucs <= 0x2195) {
if (ucs >= 0x2192) {
s[0] = 0;
s[1] = unicode_to_dingbats_1b_2192[ucs - 0x2192];
if (s[1]) return 22;
}
} else if (ucs <= 0x2469) {
if (ucs >= 0x2460) {
s[0] = 0;
s[1] = unicode_to_dingbats_1b_2460[ucs - 0x2460];
if (s[1]) return 22;
}
} else if (ucs <= 0x2666) {
if (ucs >= 0x25A0) {
s[0] = 0;
s[1] = unicode_to_dingbats_1b_25A0[ucs - 0x25A0];
if (s[1]) return 22;
}
} else if (ucs <= 0x27BE) {
if (ucs >= 0x2701) {
s[0] = 0;
s[1] = unicode_to_dingbats_1b_2701[ucs - 0x2701];
if (s[1]) return 22;
}
} else if (ucs <= 0xF8E4) {
if (ucs >= 0xF8D7) {
s[0] = 0;
s[1] = unicode_to_dingbats_1b_F8D7[ucs - 0xF8D7];
if (s[1]) return 22;
}
}
break;
case 23: /* koi8-u */
if (koi8_u_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
return 23;
}
break;
case 24: /* microsoft-cp1251 */
if (cp1251_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
return 24;
}
break;
case 26: /* gbk/cp936ext */
if (cp936ext_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
return 26;
}
break;
default:
break;
};
return -1;
}
/*const*/
int encoding_number(const char *enc) {
if (!enc || !strncmp(enc, "iso10646-1", 10)) {
return 0;
} else if (!strcmp(enc, "iso8859-1")) {
return 1;
} else if (!strcmp(enc, "iso8859-2")) {
return 2;
} else if (!strcmp(enc, "iso8859-3")) {
return 3;
} else if (!strcmp(enc, "iso8859-4")) {
return 4;
} else if (!strcmp(enc, "iso8859-5")) {
return 5;
} else if (!strcmp(enc, "iso8859-6")) {
return 6;
} else if (!strcmp(enc, "iso8859-7")) {
return 7;
} else if (!strcmp(enc, "iso8859-8")) {
return 8;
} else if (!strcmp(enc, "iso8859-9")) {
return 9;
} else if (!strcmp(enc, "iso8859-10")) {
return 10;
} else if (!strcmp(enc, "iso8859-13")) {
return 11;
} else if (!strcmp(enc, "iso8859-14")) {
return 12;
} else if (!strcmp(enc, "iso8859-15")) {
return 13;
} else if (!strcmp(enc, "koi8-r")) {
return 14;
} else if (!strcmp(enc, "big5-0") || !strcmp(enc, "big5.eten-0") ||
!strcmp(enc, "big5p-0"))
{
return 15;
} else if (!strcmp(enc, "ksc5601.1987-0")) {
return 16;
} else if (!strcmp(enc, "gb2312.1980-0") || !strcmp(enc, "gb2312.80-0") ||
!strcmp(enc, "gb2312.80&gb8565.88") || !strcmp(enc, "gb2312.80-0"))
{
return 17;
} else if (!strcmp(enc, "jisx0201.1976-0")) {
return 18;
} else if (!strcmp(enc, "jisx0208.1983-0") || !strcmp(enc, "jisx0208.1990-0")
|| !strcmp(enc, "jisx0208.1978-0"))
{
return 19;
} else if (!strcmp(enc, "jisx0212.1990-0")) {
return 20;
} else if (!strcmp(enc, "symbol")) {
return 21;
} else if (!strcmp(enc, "dingbats") || !strcmp(enc, "zapfdingbats") ||
!strcmp(enc, "zapf dingbats") || !strcmp(enc, "itc zapf dingbats"))
{
return 22;
} else if (!strcmp(enc, "koi8-u")) {
return 23;
} else if (!strcmp(enc, "microsoft-cp1251")) {
return 24;
} else if (!strcmp(enc, "iso8859-11")) {
return 25;
} else if (!strcmp(enc, "gbk-0") || !strcmp(enc, "cp936") || !strcmp(enc, "gbk")) {
return 26;
};
return -1;
}
/*
* End of "$Id$".
*/
|