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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
|
/*-------------------------------------------------------------------------
*
* Cyrillic and MULE_INTERNAL
*
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c,v 1.17 2008/03/20 10:30:04 heikki Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "fmgr.h"
#include "mb/pg_wchar.h"
#define ENCODING_GROWTH_RATE 4
PG_MODULE_MAGIC;
PG_FUNCTION_INFO_V1(koi8r_to_mic);
PG_FUNCTION_INFO_V1(mic_to_koi8r);
PG_FUNCTION_INFO_V1(iso_to_mic);
PG_FUNCTION_INFO_V1(mic_to_iso);
PG_FUNCTION_INFO_V1(win1251_to_mic);
PG_FUNCTION_INFO_V1(mic_to_win1251);
PG_FUNCTION_INFO_V1(win866_to_mic);
PG_FUNCTION_INFO_V1(mic_to_win866);
PG_FUNCTION_INFO_V1(koi8r_to_win1251);
PG_FUNCTION_INFO_V1(win1251_to_koi8r);
PG_FUNCTION_INFO_V1(koi8r_to_win866);
PG_FUNCTION_INFO_V1(win866_to_koi8r);
PG_FUNCTION_INFO_V1(win866_to_win1251);
PG_FUNCTION_INFO_V1(win1251_to_win866);
PG_FUNCTION_INFO_V1(iso_to_koi8r);
PG_FUNCTION_INFO_V1(koi8r_to_iso);
PG_FUNCTION_INFO_V1(iso_to_win1251);
PG_FUNCTION_INFO_V1(win1251_to_iso);
PG_FUNCTION_INFO_V1(iso_to_win866);
PG_FUNCTION_INFO_V1(win866_to_iso);
extern Datum koi8r_to_mic(PG_FUNCTION_ARGS);
extern Datum mic_to_koi8r(PG_FUNCTION_ARGS);
extern Datum iso_to_mic(PG_FUNCTION_ARGS);
extern Datum mic_to_iso(PG_FUNCTION_ARGS);
extern Datum win1251_to_mic(PG_FUNCTION_ARGS);
extern Datum mic_to_win1251(PG_FUNCTION_ARGS);
extern Datum win866_to_mic(PG_FUNCTION_ARGS);
extern Datum mic_to_win866(PG_FUNCTION_ARGS);
extern Datum koi8r_to_win1251(PG_FUNCTION_ARGS);
extern Datum win1251_to_koi8r(PG_FUNCTION_ARGS);
extern Datum koi8r_to_win866(PG_FUNCTION_ARGS);
extern Datum win866_to_koi8r(PG_FUNCTION_ARGS);
extern Datum win866_to_win1251(PG_FUNCTION_ARGS);
extern Datum win1251_to_win866(PG_FUNCTION_ARGS);
extern Datum iso_to_koi8r(PG_FUNCTION_ARGS);
extern Datum koi8r_to_iso(PG_FUNCTION_ARGS);
extern Datum iso_to_win1251(PG_FUNCTION_ARGS);
extern Datum win1251_to_iso(PG_FUNCTION_ARGS);
extern Datum iso_to_win866(PG_FUNCTION_ARGS);
extern Datum win866_to_iso(PG_FUNCTION_ARGS);
/* ----------
* conv_proc(
* INTEGER, -- source encoding id
* INTEGER, -- destination encoding id
* CSTRING, -- source string (null terminated C string)
* CSTRING, -- destination string (null terminated C string)
* INTEGER -- source string length
* ) returns VOID;
* ----------
*/
static void koi8r2mic(const unsigned char *l, unsigned char *p, int len);
static void mic2koi8r(const unsigned char *mic, unsigned char *p, int len);
static void iso2mic(const unsigned char *l, unsigned char *p, int len);
static void mic2iso(const unsigned char *mic, unsigned char *p, int len);
static void win12512mic(const unsigned char *l, unsigned char *p, int len);
static void mic2win1251(const unsigned char *mic, unsigned char *p, int len);
static void win8662mic(const unsigned char *l, unsigned char *p, int len);
static void mic2win866(const unsigned char *mic, unsigned char *p, int len);
Datum
koi8r_to_mic(PG_FUNCTION_ARGS)
{
unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
Assert(PG_GETARG_INT32(0) == PG_KOI8R);
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
Assert(len >= 0);
koi8r2mic(src, dest, len);
PG_RETURN_VOID();
}
Datum
mic_to_koi8r(PG_FUNCTION_ARGS)
{
unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
Assert(PG_GETARG_INT32(1) == PG_KOI8R);
Assert(len >= 0);
mic2koi8r(src, dest, len);
PG_RETURN_VOID();
}
Datum
iso_to_mic(PG_FUNCTION_ARGS)
{
unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
Assert(PG_GETARG_INT32(0) == PG_ISO_8859_5);
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
Assert(len >= 0);
iso2mic(src, dest, len);
PG_RETURN_VOID();
}
Datum
mic_to_iso(PG_FUNCTION_ARGS)
{
unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
Assert(PG_GETARG_INT32(1) == PG_ISO_8859_5);
Assert(len >= 0);
mic2iso(src, dest, len);
PG_RETURN_VOID();
}
Datum
win1251_to_mic(PG_FUNCTION_ARGS)
{
unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
Assert(PG_GETARG_INT32(0) == PG_WIN1251);
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
Assert(len >= 0);
win12512mic(src, dest, len);
PG_RETURN_VOID();
}
Datum
mic_to_win1251(PG_FUNCTION_ARGS)
{
unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
Assert(PG_GETARG_INT32(1) == PG_WIN1251);
Assert(len >= 0);
mic2win1251(src, dest, len);
PG_RETURN_VOID();
}
Datum
win866_to_mic(PG_FUNCTION_ARGS)
{
unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
Assert(PG_GETARG_INT32(0) == PG_WIN866);
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
Assert(len >= 0);
win8662mic(src, dest, len);
PG_RETURN_VOID();
}
Datum
mic_to_win866(PG_FUNCTION_ARGS)
{
unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
Assert(PG_GETARG_INT32(1) == PG_WIN866);
Assert(len >= 0);
mic2win866(src, dest, len);
PG_RETURN_VOID();
}
Datum
koi8r_to_win1251(PG_FUNCTION_ARGS)
{
unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
unsigned char *buf;
Assert(PG_GETARG_INT32(0) == PG_KOI8R);
Assert(PG_GETARG_INT32(1) == PG_WIN1251);
Assert(len >= 0);
buf = palloc(len * ENCODING_GROWTH_RATE);
koi8r2mic(src, buf, len);
mic2win1251(buf, dest, strlen((char *) buf));
pfree(buf);
PG_RETURN_VOID();
}
Datum
win1251_to_koi8r(PG_FUNCTION_ARGS)
{
unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
unsigned char *buf;
Assert(PG_GETARG_INT32(0) == PG_WIN1251);
Assert(PG_GETARG_INT32(1) == PG_KOI8R);
Assert(len >= 0);
buf = palloc(len * ENCODING_GROWTH_RATE);
win12512mic(src, buf, len);
mic2koi8r(buf, dest, strlen((char *) buf));
pfree(buf);
PG_RETURN_VOID();
}
Datum
koi8r_to_win866(PG_FUNCTION_ARGS)
{
unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
unsigned char *buf;
Assert(PG_GETARG_INT32(0) == PG_KOI8R);
Assert(PG_GETARG_INT32(1) == PG_WIN866);
Assert(len >= 0);
buf = palloc(len * ENCODING_GROWTH_RATE);
koi8r2mic(src, buf, len);
mic2win866(buf, dest, strlen((char *) buf));
pfree(buf);
PG_RETURN_VOID();
}
Datum
win866_to_koi8r(PG_FUNCTION_ARGS)
{
unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
unsigned char *buf;
Assert(PG_GETARG_INT32(0) == PG_WIN866);
Assert(PG_GETARG_INT32(1) == PG_KOI8R);
Assert(len >= 0);
buf = palloc(len * ENCODING_GROWTH_RATE);
win8662mic(src, buf, len);
mic2koi8r(buf, dest, strlen((char *) buf));
pfree(buf);
PG_RETURN_VOID();
}
Datum
win866_to_win1251(PG_FUNCTION_ARGS)
{
unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
unsigned char *buf;
Assert(PG_GETARG_INT32(0) == PG_WIN866);
Assert(PG_GETARG_INT32(1) == PG_WIN1251);
Assert(len >= 0);
/*
* Note: There are a few characters like the "Numero" sign that exist in
* all the other cyrillic encodings (win1251, ISO_8859-5 and cp866), but
* not in KOI8R. As we use MULE_INTERNAL/KOI8R as an intermediary, we
* will fail to convert those characters.
*/
buf = palloc(len * ENCODING_GROWTH_RATE);
win8662mic(src, buf, len);
mic2win1251(buf, dest, strlen((char *) buf));
pfree(buf);
PG_RETURN_VOID();
}
Datum
win1251_to_win866(PG_FUNCTION_ARGS)
{
unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
unsigned char *buf;
Assert(PG_GETARG_INT32(0) == PG_WIN1251);
Assert(PG_GETARG_INT32(1) == PG_WIN866);
Assert(len >= 0);
/* Use mic/KOI8R as intermediary, see comment in win866_to_win1251() */
buf = palloc(len * ENCODING_GROWTH_RATE);
win12512mic(src, buf, len);
mic2win866(buf, dest, strlen((char *) buf));
pfree(buf);
PG_RETURN_VOID();
}
Datum
iso_to_koi8r(PG_FUNCTION_ARGS)
{
unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
unsigned char *buf;
Assert(PG_GETARG_INT32(0) == PG_ISO_8859_5);
Assert(PG_GETARG_INT32(1) == PG_KOI8R);
Assert(len >= 0);
buf = palloc(len * ENCODING_GROWTH_RATE);
iso2mic(src, buf, len);
mic2koi8r(buf, dest, strlen((char *) buf));
pfree(buf);
PG_RETURN_VOID();
}
Datum
koi8r_to_iso(PG_FUNCTION_ARGS)
{
unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
unsigned char *buf;
Assert(PG_GETARG_INT32(0) == PG_KOI8R);
Assert(PG_GETARG_INT32(1) == PG_ISO_8859_5);
Assert(len >= 0);
buf = palloc(len * ENCODING_GROWTH_RATE);
koi8r2mic(src, buf, len);
mic2iso(buf, dest, strlen((char *) buf));
pfree(buf);
PG_RETURN_VOID();
}
Datum
iso_to_win1251(PG_FUNCTION_ARGS)
{
unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
unsigned char *buf;
Assert(PG_GETARG_INT32(0) == PG_ISO_8859_5);
Assert(PG_GETARG_INT32(1) == PG_WIN1251);
Assert(len >= 0);
/* Use mic/KOI8R as intermediary, see comment in win866_to_win1251() */
buf = palloc(len * ENCODING_GROWTH_RATE);
iso2mic(src, buf, len);
mic2win1251(buf, dest, strlen((char *) buf));
pfree(buf);
PG_RETURN_VOID();
}
Datum
win1251_to_iso(PG_FUNCTION_ARGS)
{
unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
unsigned char *buf;
Assert(PG_GETARG_INT32(0) == PG_WIN1251);
Assert(PG_GETARG_INT32(1) == PG_ISO_8859_5);
Assert(len >= 0);
/* Use mic/KOI8R as intermediary, see comment in win866_to_win1251() */
buf = palloc(len * ENCODING_GROWTH_RATE);
win12512mic(src, buf, len);
mic2iso(buf, dest, strlen((char *) buf));
pfree(buf);
PG_RETURN_VOID();
}
Datum
iso_to_win866(PG_FUNCTION_ARGS)
{
unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
unsigned char *buf;
Assert(PG_GETARG_INT32(0) == PG_ISO_8859_5);
Assert(PG_GETARG_INT32(1) == PG_WIN866);
Assert(len >= 0);
/* Use mic/KOI8R as intermediary, see comment in win866_to_win1251() */
buf = palloc(len * ENCODING_GROWTH_RATE);
iso2mic(src, buf, len);
mic2win866(buf, dest, strlen((char *) buf));
pfree(buf);
PG_RETURN_VOID();
}
Datum
win866_to_iso(PG_FUNCTION_ARGS)
{
unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
int len = PG_GETARG_INT32(4);
unsigned char *buf;
Assert(PG_GETARG_INT32(0) == PG_WIN866);
Assert(PG_GETARG_INT32(1) == PG_ISO_8859_5);
Assert(len >= 0);
/* Use mic/KOI8R as intermediary, see comment in win866_to_win1251() */
buf = palloc(len * ENCODING_GROWTH_RATE);
win8662mic(src, buf, len);
mic2iso(buf, dest, strlen((char *) buf));
pfree(buf);
PG_RETURN_VOID();
}
/*
* Cyrillic support
* currently supported Cyrillic encodings:
*
* KOI8-R (this is the charset for the mule internal code
* for Cyrillic)
* ISO-8859-5
* Microsoft's CP1251(windows-1251)
* Alternativny Variant (MS-DOS CP866)
*/
/* koi8r2mic: KOI8-R to Mule internal code */
static void
koi8r2mic(const unsigned char *l, unsigned char *p, int len)
{
latin2mic(l, p, len, LC_KOI8_R, PG_KOI8R);
}
/* mic2koi8r: Mule internal code to KOI8-R */
static void
mic2koi8r(const unsigned char *mic, unsigned char *p, int len)
{
mic2latin(mic, p, len, LC_KOI8_R, PG_KOI8R);
}
/* iso2mic: ISO-8859-5 to Mule internal code */
static void
iso2mic(const unsigned char *l, unsigned char *p, int len)
{
static const unsigned char iso2koi[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xe1, 0xe2, 0xf7, 0xe7, 0xe4, 0xe5, 0xf6, 0xfa,
0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0,
0xf2, 0xf3, 0xf4, 0xf5, 0xe6, 0xe8, 0xe3, 0xfe,
0xfb, 0xfd, 0xff, 0xf9, 0xf8, 0xfc, 0xe0, 0xf1,
0xc1, 0xc2, 0xd7, 0xc7, 0xc4, 0xc5, 0xd6, 0xda,
0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0,
0xd2, 0xd3, 0xd4, 0xd5, 0xc6, 0xc8, 0xc3, 0xde,
0xdb, 0xdd, 0xdf, 0xd9, 0xd8, 0xdc, 0xc0, 0xd1,
0x00, 0xa3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
latin2mic_with_table(l, p, len, LC_KOI8_R, PG_ISO_8859_5, iso2koi);
}
/* mic2iso: Mule internal code to ISO8859-5 */
static void
mic2iso(const unsigned char *mic, unsigned char *p, int len)
{
static const unsigned char koi2iso[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xf1, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xa1, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xee, 0xd0, 0xd1, 0xe6, 0xd4, 0xd5, 0xe4, 0xd3,
0xe5, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde,
0xdf, 0xef, 0xe0, 0xe1, 0xe2, 0xe3, 0xd6, 0xd2,
0xec, 0xeb, 0xd7, 0xe8, 0xed, 0xe9, 0xe7, 0xea,
0xce, 0xb0, 0xb1, 0xc6, 0xb4, 0xb5, 0xc4, 0xb3,
0xc5, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe,
0xbf, 0xcf, 0xc0, 0xc1, 0xc2, 0xc3, 0xb6, 0xb2,
0xcc, 0xcb, 0xb7, 0xc8, 0xcd, 0xc9, 0xc7, 0xca
};
mic2latin_with_table(mic, p, len, LC_KOI8_R, PG_ISO_8859_5, koi2iso);
}
/* win2mic: CP1251 to Mule internal code */
static void
win12512mic(const unsigned char *l, unsigned char *p, int len)
{
static const unsigned char win2koi[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00,
0xb3, 0x00, 0xb4, 0x00, 0x00, 0x00, 0x00, 0xb7,
0x00, 0x00, 0xb6, 0xa6, 0xad, 0x00, 0x00, 0x00,
0xa3, 0x00, 0xa4, 0x00, 0x00, 0x00, 0x00, 0xa7,
0xe1, 0xe2, 0xf7, 0xe7, 0xe4, 0xe5, 0xf6, 0xfa,
0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0,
0xf2, 0xf3, 0xf4, 0xf5, 0xe6, 0xe8, 0xe3, 0xfe,
0xfb, 0xfd, 0xff, 0xf9, 0xf8, 0xfc, 0xe0, 0xf1,
0xc1, 0xc2, 0xd7, 0xc7, 0xc4, 0xc5, 0xd6, 0xda,
0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0,
0xd2, 0xd3, 0xd4, 0xd5, 0xc6, 0xc8, 0xc3, 0xde,
0xdb, 0xdd, 0xdf, 0xd9, 0xd8, 0xdc, 0xc0, 0xd1
};
latin2mic_with_table(l, p, len, LC_KOI8_R, PG_WIN1251, win2koi);
}
/* mic2win: Mule internal code to CP1251 */
static void
mic2win1251(const unsigned char *mic, unsigned char *p, int len)
{
static const unsigned char koi2win[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xb8, 0xba, 0x00, 0xb3, 0xbf,
0x00, 0x00, 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00,
0x00, 0x00, 0x00, 0xa8, 0xaa, 0x00, 0xb2, 0xaf,
0x00, 0x00, 0x00, 0x00, 0x00, 0xa5, 0x00, 0x00,
0xfe, 0xe0, 0xe1, 0xf6, 0xe4, 0xe5, 0xf4, 0xe3,
0xf5, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee,
0xef, 0xff, 0xf0, 0xf1, 0xf2, 0xf3, 0xe6, 0xe2,
0xfc, 0xfb, 0xe7, 0xf8, 0xfd, 0xf9, 0xf7, 0xfa,
0xde, 0xc0, 0xc1, 0xd6, 0xc4, 0xc5, 0xd4, 0xc3,
0xd5, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce,
0xcf, 0xdf, 0xd0, 0xd1, 0xd2, 0xd3, 0xc6, 0xc2,
0xdc, 0xdb, 0xc7, 0xd8, 0xdd, 0xd9, 0xd7, 0xda
};
mic2latin_with_table(mic, p, len, LC_KOI8_R, PG_WIN1251, koi2win);
}
/* win8662mic: CP866 to Mule internal code */
static void
win8662mic(const unsigned char *l, unsigned char *p, int len)
{
static const unsigned char win8662koi[] = {
0xe1, 0xe2, 0xf7, 0xe7, 0xe4, 0xe5, 0xf6, 0xfa,
0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0,
0xf2, 0xf3, 0xf4, 0xf5, 0xe6, 0xe8, 0xe3, 0xfe,
0xfb, 0xfd, 0xff, 0xf9, 0xf8, 0xfc, 0xe0, 0xf1,
0xc1, 0xc2, 0xd7, 0xc7, 0xc4, 0xc5, 0xd6, 0xda,
0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xd2, 0xd3, 0xd4, 0xd5, 0xc6, 0xc8, 0xc3, 0xde,
0xdb, 0xdd, 0xdf, 0xd9, 0xd8, 0xdc, 0xc0, 0xd1,
0xb3, 0xa3, 0xb4, 0xa4, 0xb7, 0xa7, 0x00, 0x00,
0xb6, 0xa6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
latin2mic_with_table(l, p, len, LC_KOI8_R, PG_WIN866, win8662koi);
}
/* mic2win866: Mule internal code to CP866 */
static void
mic2win866(const unsigned char *mic, unsigned char *p, int len)
{
static const unsigned char koi2win866[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xf1, 0xf3, 0x00, 0xf9, 0xf5,
0x00, 0x00, 0x00, 0x00, 0x00, 0xad, 0x00, 0x00,
0x00, 0x00, 0x00, 0xf0, 0xf2, 0x00, 0xf8, 0xf4,
0x00, 0x00, 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00,
0xee, 0xa0, 0xa1, 0xe6, 0xa4, 0xa5, 0xe4, 0xa3,
0xe5, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae,
0xaf, 0xef, 0xe0, 0xe1, 0xe2, 0xe3, 0xa6, 0xa2,
0xec, 0xeb, 0xa7, 0xe8, 0xed, 0xe9, 0xe7, 0xea,
0x9e, 0x80, 0x81, 0x96, 0x84, 0x85, 0x94, 0x83,
0x95, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e,
0x8f, 0x9f, 0x90, 0x91, 0x92, 0x93, 0x86, 0x82,
0x9c, 0x9b, 0x87, 0x98, 0x9d, 0x99, 0x97, 0x9a
};
mic2latin_with_table(mic, p, len, LC_KOI8_R, PG_WIN866, koi2win866);
}
|