summaryrefslogtreecommitdiffstats
path: root/source3/include/kanji.h
blob: 58774a699dfd2468c0917e03e40d27379f5533a0 (plain)
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
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
/* 
   Unix SMB/Netbios implementation.
   Version 1.9.
   Kanji Extensions
   Copyright (C) Andrew Tridgell 1992-1998
   
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

   Adding for Japanese language by <fujita@ainix.isac.co.jp> 1994.9.5
     and extend coding system to EUC/SJIS/JIS/HEX at 1994.10.11
     and add all jis codes sequence at 1995.8.16
     Notes: Hexadecimal code by <ohki@gssm.otuka.tsukuba.ac.jp>
     and add upper/lower case conversion 1997.8.21
*/
#ifndef _KANJI_H_
#define _KANJI_H_

/* FOR SHIFT JIS CODE */
#define is_shift_jis(c) \
    ((0x81 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0x9f) \
     || (0xe0 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xfc))
#define is_shift_jis2(c) \
    (0x40 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xfc \
    && ((unsigned char) (c)) != 0x7f)
#define is_kana(c) ((0xa0 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xdf))

/* case conversion */
#define is_sj_upper2(c) \
  ((0x60 <= (unsigned char) (c)) && ((unsigned char) (c) <= 0x79))
#define is_sj_lower2(c) \
  ((0x81 <= (unsigned char) (c)) && ((unsigned char) (c) <= 0x9A))
#define sjis_alph 0x82
#define is_sj_alph(c) (sjis_alph == (unsigned char) (c))
#define is_sj_upper(c1, c2) (is_sj_alph (c1) && is_sj_upper2 (c2))
#define is_sj_lower(c1, c2) (is_sj_alph (c1) && is_sj_lower2 (c2))
#define sj_toupper2(c) \
    (is_sj_lower2 (c) ? ((int) ((unsigned char) (c) - 0x81 + 0x60)) : \
     ((int) (unsigned char) (c)))
#define sj_tolower2(c) \
    (is_sj_upper2 (c) ? ((int) ((unsigned char) (c) - 0x60 + 0x81)) : \
     ((int) (unsigned char) (c)))

#define is_sj_ru_upper2(c) \
  ((0x40 <= (unsigned char) (c)) && ((unsigned char) (c) <= 0x60))
#define is_sj_ru_lower2(c) \
  (((0x70 <= (unsigned char) (c)) && ((unsigned char) (c) <= 0x7e)) || \
   ((0x80 <= (unsigned char) (c)) && ((unsigned char) (c) <= 0x91)))
#define sjis_russian 0x84
#define is_sj_russian(c) (sjis_russian == (unsigned char) (c))
#define is_sj_ru_upper(c1, c2) (is_sj_russian (c1) && is_sj_ru_upper2 (c2))
#define is_sj_ru_lower(c1, c2) (is_sj_russian (c1) && is_sj_ru_lower2 (c2))
#define sj_ru_toupper2(c) \
    (is_sj_ru_lower2 (c) ? ((int) ((unsigned char) (c) + \
	(((unsigned char)(c) >= 0x4f) ? (0x70 - 0x40) : (0x80 - 0x4f)))) : \
	((int) (unsigned char) (c)))
#define sj_ru_tolower2(c) \
    (is_sj_ru_upper2 (c) ? ((int) ((unsigned char) (c) - \
	(((unsigned char)(c) >= 0x80) ? (0x70 - 0x40) : (0x80 - 0x4f)))) : \
        ((int) (unsigned char) (c)))

#ifdef _KANJI_C_
/* FOR EUC CODE */
#define euc_kana (0x8e)
#define is_euc_kana(c) (((unsigned char) (c)) == euc_kana)
#define is_euc(c)  (0xa0 < ((unsigned char) (c)) && ((unsigned char) (c)) < 0xff)

#define euc_sup (0x8f)
#define is_euc_sup(c) (((unsigned char ) (c)) == euc_sup) 

/* FOR JIS CODE */
/* default jis third shift code, use for output */
#ifndef JIS_KSO
#define JIS_KSO 'B'
#endif
#ifndef JIS_KSI
#define JIS_KSI 'J'
#endif
/* in: \E$B or \E$@ */
/* out: \E(J or \E(B or \E(H */
#define jis_esc (0x1b)
#define jis_so (0x0e)
#define jis_so1 ('$')
#define jis_so2 ('B')
#define jis_si (0x0f)
#define jis_si1 ('(')
#define jis_si2 ('J')
#define is_esc(c) (((unsigned char) (c)) == jis_esc)
#define is_so1(c) (((unsigned char) (c)) == jis_so1)
#define is_so2(c) (((unsigned char) (c)) == jis_so2 || ((unsigned char) (c)) == '@')
#define is_si1(c) (((unsigned char) (c)) == jis_si1)
#define is_si2(c) (((unsigned char) (c)) == jis_si2 || ((unsigned char) (c)) == 'B' \
    || ((unsigned char) (c)) == 'H')
#define is_so(c) (((unsigned char) (c)) == jis_so)
#define is_si(c) (((unsigned char) (c)) == jis_si)
#define junet_kana1 ('(')
#define junet_kana2 ('I')
#define is_juk1(c) (((unsigned char) (c)) == junet_kana1)
#define is_juk2(c) (((unsigned char) (c)) == junet_kana2)

#define _KJ_ROMAN (0)
#define _KJ_KANJI (1)
#define _KJ_KANA (2)

/* FOR HEX */
#define HEXTAG ':'
#define hex2bin(x)						      \
    ( ((int) '0' <= ((int) (x)) && ((int) (x)) <= (int)'9')?	      \
        (((int) (x))-(int)'0'):					      \
      ((int) 'a'<= ((int) (x)) && ((int) (x))<= (int) 'f')?	      \
        (((int) (x)) - (int)'a'+10):				      \
      (((int) (x)) - (int)'A'+10) )
#define bin2hex(x)						      \
    ( (((int) (x)) >= 10)? (((int) (x))-10 + (int) 'a'): (((int) (x)) + (int) '0') )

/* For Hangul (Korean - code page 949). */
#define is_hangul(c) ((0x81 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xfd))

/* For traditional Chinese (known as Big5 encoding - code page 950). */
#define is_big5_c1(c) ((0xa1 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xf9)) 

/* For simplified Chinese (code page - 936). */
#define is_simpch_c1(c) ((0xa1 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xf7))

#else /* not _KANJI_C_ */

/*
 * The following is needed for AIX systems that have
 * their own #defines for strchr, strrchr, strstr
 * and strtok.
 */

#ifdef strchr
#undef strchr
#endif /* strchr */

#ifdef strrchr
#undef strrchr
#endif /* strrchr */

#ifdef strstr
#undef strstr
#endif /* strstr */

#ifdef strtok
#undef strtok
#endif /* strtok */

/* Ensure we use our definitions in all other files than kanji.c. */

/* Function pointers we will replace. */
extern char *(*multibyte_strchr)(const char *s, int c);
extern char *(*multibyte_strrchr)(const char *s, int c);
extern char *(*multibyte_strstr)(const char *s1, const char *s2);
extern char *(*multibyte_strtok)(char *s1, const char *s2);
extern char *(*_dos_to_unix)(char *str, BOOL overwrite);
extern char *(*_unix_to_dos)(char *str, BOOL overwrite);
extern char *(*_dos_to_dos)(char *str, BOOL overwrite);
extern BOOL (*is_multibyte_char)(char c);
extern int (*_skip_multibyte_char)(char c);

#define strchr(s1, c) ((*multibyte_strchr)((s1), (c)))
#define strrchr(s1, c) ((*multibyte_strrchr)((s1), (c)))
#define strstr(s1, s2) ((*multibyte_strstr)((s1), (s2)))
#define strtok(s1, s2) ((*multibyte_strtok)((s1), (s2)))
#define dos_to_unix(x,y) ((*_dos_to_unix)((x), (y)))
#define unix_to_dos(x,y) ((*_unix_to_dos)((x), (y)))
#define dos_to_dos(x,y) ((*_dos_to_dos)((x), (y)))
#define skip_multibyte_char(c) ((*_skip_multibyte_char)((c)))

#endif /* _KANJI_C_ */

#define UNKNOWN_CODE (-1)
#define SJIS_CODE (0)
#define EUC_CODE (1)
#define JIS7_CODE (2)
#define JIS8_CODE (3)
#define JUNET_CODE (4)
#define HEX_CODE (5)
#define CAP_CODE (6)
#define DOSV_CODE SJIS_CODE
#define EUC3_CODE (7)
#define UTF8_CODE (8)

#ifdef _KANJI_C_

/* For conversion */

#define EXTSJISC(c)   (0xf0 <= ((unsigned char)(c)) \
		       && ((unsigned char)(c) <= 0xfc)) 
#define GETAHI (0x81)
#define GETALO (0xac)

typedef struct _sjis_regur_t {
	int start;
	int end;
	int rstart;
} sjis_regur_t;

/*  When Converting to EUC and JIS,  there is no room for 
 *  these SJIS codes whose hi byte is larger than 0xf0.
 *  
 *  So we must drop or convert it to harmless code.
 *  This is not standard way, so it is ad hoc but practical. 
 *  It is also thought of backward and future compatibility.
 * 
 *      Miura.
 */

static sjis_regur_t sjisconv[] = {
{0xfa40, 0xfa49, 0xeeef},
{0xfa4a, 0xfa53, 0x8754},
{0xfa54, 0xfa54, 0x81ca},
{0xfa55, 0xfa57, 0xeefa},
{0xfa58, 0xfa58, 0x878a},
{0xfa59, 0xfa59, 0x8782},
{0xfa5a, 0xfa5a, 0x8784},
{0xfa5b, 0xfa5b, 0x81e6},
{0xfa5c, 0xfa7e, 0xed40},
{0xfa80, 0xfa9b, 0xed63},
{0xfa9c, 0xfafc, 0xed80},
{0xfb40, 0xfb5b, 0xede1},
{0xfb5c, 0xfb7e, 0xee40},
{0xfb80, 0xfb9b, 0xee63},
{0xfb9c, 0xfbfc, 0xee80},
{0xfc40, 0xfc4b, 0xeee1}
};
#define	SJISCONVTBLSIZ	(sizeof(sjisconv) / sizeof(sjis_regur_t))

static sjis_regur_t sjisrev[] = {
{0x81ca, 0x81ca, 0xfa54},
{0x81e6, 0x81e6, 0xfa5b},
{0x8754, 0x875d, 0xfa4a},
{0x8782, 0x8782, 0xfa59},
{0x8784, 0x8784, 0xfa5a},
{0x878a, 0x878a, 0xfa58},
{0xed40, 0xed62, 0xfa5c},
{0xed63, 0xed7e, 0xfa80},
{0xed80, 0xede0, 0xfa9c},
{0xede1, 0xedfc, 0xfb40},
{0xee40, 0xee62, 0xfb5c},
{0xee63, 0xee7e, 0xfb80},
{0xee80, 0xeee0, 0xfb9c},
{0xeee1, 0xeeec, 0xfc40},
{0xeeef, 0xeef8, 0xfa40},
{0xeefa, 0xeefc, 0xfa55}
};
#define	SJISREVTBLSIZ	(sizeof(sjisrev) / sizeof(sjis_regur_t))

/* EUC3BYTE DEFINITIONS */

typedef struct _sjis_euc_map_t {
  int  sjis;
  int  euc;
} sjis_euc_map_t;
 
static sjis_euc_map_t euc3conv2[] = {
{0x8754 , 0xf3fd},
{0x8755 , 0xf3fe},
{0x8756 , 0xf4a1},
{0x8757 , 0xf4a2},
{0x8758 , 0xf4a3},
{0x8759 , 0xf4a4},
{0x875a , 0xf4a5},
{0x875b , 0xf4a6},
{0x875c , 0xf4a7},
{0x875d , 0xf4a8},
{0x8782 , 0xf4ac},
{0x8784 , 0xf4ad},
{0x878a , 0xf4ab}
};
#define	EUC3CONV2TBLSIZ	(sizeof(euc3conv2) / sizeof(sjis_euc_map_t))


/* IBM Kanji to EUC 3byte */
static int euc3conv[] = {
/* 0xfa40 */ 
0xf3f3, 0xf3f4, 0xf3f5, 0xf3f6, 0xf3f7, 0xf3f8, 0xf3f9, 0xf3fa, 0xf3fb, 0xf3fc, 0xf3fd, 0xf3fe, 0xf4a1, 0xf4a2, 0xf4a3, 0xf4a4,
/* 0xfa50 */
0xf4a5, 0xf4a6, 0xf4a7, 0xf4a8, 0, 0xa2c3, 0xf4a9, 0xf4aa, 0xf4ab, 0xf4ac, 0xf4ad, 0, 0xd4e3, 0xdcdf, 0xe4e9, 0xe3f8,
/* 0xfa60 */
0x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) / sizeof(int))

/* EUC3byte to SJIS Code */

typedef struct _sjis_euc_revmap_t {
  int  euc;
  int  sjis;
} sjis_euc_revmap_t;

static sjis_euc_revmap_t euc3rev[] = {
{0xa2c3, 0xfa55},
{0xb0a9, 0xfa68},
{0xb0c8, 0xfa69},
{0xb0d2, 0xfa6b},
{0xb0d4, 0xfa6c},
{0xb0e3, 0xfa6d},
{0xb0ee, 0xfa6e},
{0xb1a3, 0xfa70},
{0xb1a7, 0xfa6f},
{0xb1a9, 0xfa72},
{0xb1ac, 0xfa71},
{0xb1bb, 0xfa61},
{0xb1be, 0xfa73},
{0xb1c8, 0xfa76},
{0xb1d7, 0xfa77},
{0xb1d8, 0xfa75},
{0xb1df, 0xfa74},
{0xb1e1, 0xfa7a},
{0xb1e3, 0xfa78},
{0xb1f4, 0xfa79},
{0xb2a3, 0xfa7b},
{0xb2bb, 0xfa7d},
{0xb2e6, 0xfa7e},
{0xb2ed, 0xfa80},
{0xb2f5, 0xfa81},
{0xb2fc, 0xfa82},
{0xb3b5, 0xfa84},
{0xb3d8, 0xfa85},
{0xb3db, 0xfa86},
{0xb3dd, 0xfb77},
{0xb3e5, 0xfa87},
{0xb3ee, 0xfa88},
{0xb3fb, 0xfa89},
{0xb4c0, 0xfa8c},
{0xb4c7, 0xfa8d},
{0xb4d0, 0xfa8e},
{0xb4de, 0xfa8f},
{0xb5aa, 0xfa91},
{0xb5af, 0xfa93},
{0xb5c4, 0xfa94},
{0xb5e8, 0xfa95},
{0xb7c2, 0xfa97},
{0xb7e4, 0xfa98},
{0xb7e7, 0xfa9a},
{0xb7e8, 0xfa99},
{0xb8ce, 0xfa9e},
{0xb8e1, 0xfa9f},
{0xb8f5, 0xfaa0},
{0xb8f7, 0xfaa1},
{0xb8f8, 0xfaa2},
{0xb8fc, 0xfaa3},
{0xb9af, 0xfaa4},
{0xb9b7, 0xfaa5},
{0xbabe, 0xfaa6},
{0xbadb, 0xfaa7},
{0xbae1, 0xfaa9},
{0xbaeb, 0xfaab},
{0xbbb3, 0xfaac},
{0xbbb8, 0xfaad},
{0xbbca, 0xfaaf},
{0xbbd0, 0xfab2},
{0xbbde, 0xfab3},
{0xbbf4, 0xfab4},
{0xbbf5, 0xfab5},
{0xbbf9, 0xfab6},
{0xbce4, 0xfab7},
{0xbced, 0xfab8},
{0xbcf4, 0xfa67},
{0xbcfe, 0xfab9},
{0xbdc2, 0xfabb},
{0xbde7, 0xfabc},
{0xbdf0, 0xfabe},
{0xbeac, 0xfac0},
{0xbeb0, 0xfabf},
{0xbeb3, 0xfac2},
{0xbebd, 0xfac3},
{0xbec9, 0xfac5},
{0xbecd, 0xfac4},
{0xbee4, 0xfac6},
{0xbfa8, 0xfac7},
{0xbfc9, 0xfac8},
{0xc0c4, 0xfac9},
{0xc0e4, 0xfaca},
{0xc0f4, 0xfacb},
{0xc1a6, 0xfacc},
{0xc1f5, 0xface},
{0xc1f8, 0xfad1},
{0xc1fc, 0xfacf},
{0xc2a1, 0xfad3},
{0xc2a5, 0xfad4},
{0xc2ab, 0xfad2},
{0xc2ad, 0xfa63},
{0xc2b8, 0xfad6},
{0xc2ba, 0xfad7},
{0xc2bf, 0xfa66},
{0xc2c4, 0xfad9},
{0xc2d2, 0xfada},
{0xc2d7, 0xfadb},
{0xc2db, 0xfadc},
{0xc2de, 0xfadd},
{0xc2ed, 0xfade},
{0xc2f0, 0xfadf},
{0xc3a1, 0xfae1},
{0xc3b5, 0xfae2},
{0xc3b9, 0xfae4},
{0xc3c9, 0xfae3},
{0xc3d8, 0xfae6},
{0xc3fc, 0xfa64},
{0xc3fe, 0xfae7},
{0xc4cc, 0xfae9},
{0xc4d9, 0xfaeb},
{0xc4ea, 0xfaec},
{0xc4fd, 0xfaed},
{0xc5a7, 0xfaef},
{0xc5b5, 0xfaf0},
{0xc5b6, 0xfaf1},
{0xc5d5, 0xfaf3},
{0xc6b8, 0xfaf4},
{0xc6d7, 0xfaf5},
{0xc6e0, 0xfaf6},
{0xc6e3, 0xfaf8},
{0xc6ea, 0xfaf7},
{0xc7a1, 0xfaf9},
{0xc7ab, 0xfafa},
{0xc7c3, 0xfafc},
{0xc7c7, 0xfafb},
{0xc7cb, 0xfb40},
{0xc7cf, 0xfb41},
{0xc7d9, 0xfb42},
{0xc7e6, 0xfb45},
{0xc7eb, 0xfb48},
{0xc7ee, 0xfb46},
{0xc7f0, 0xfb49},
{0xc7fc, 0xfb47},
{0xc8b1, 0xfb4a},
{0xc8e5, 0xfb4b},
{0xc8f8, 0xfb4c},
{0xc9a6, 0xfb4d},
{0xc9ab, 0xfb4e},
{0xc9ad, 0xfb4f},
{0xc9ca, 0xfb51},
{0xc9d3, 0xfb52},
{0xc9e3, 0xfb54},
{0xc9e9, 0xfb53},
{0xc9f4, 0xfb56},
{0xc9f5, 0xfb57},
{0xc9fc, 0xfb55},
{0xcab3, 0xfb59},
{0xcabd, 0xfb5a},
{0xcaef, 0xfb5b},
{0xcaf1, 0xfb5c},
{0xcbae, 0xfb5d},
{0xcbca, 0xfb5f},
{0xcbe6, 0xfb60},
{0xcbea, 0xfb61},
{0xcbee, 0xfb64},
{0xcbf0, 0xfb62},
{0xcbf4, 0xfb63},
{0xcbf9, 0xfb66},
{0xcca5, 0xfb65},
{0xccab, 0xfb67},
{0xccad, 0xfb69},
{0xccae, 0xfb68},
{0xccb2, 0xfb6a},
{0xccc2, 0xfb6b},
{0xccd0, 0xfb6c},
{0xccd9, 0xfb6d},
{0xcdaa, 0xfaa8},
{0xcdbb, 0xfb6f},
{0xceba, 0xfb73},
{0xcebb, 0xfb71},
{0xcec3, 0xfb74},
{0xcef2, 0xfb76},
{0xcfd5, 0xfb78},
{0xcfe2, 0xfb79},
{0xcfe9, 0xfb7a},
{0xcfed, 0xfb7b},
{0xd0e5, 0xfb81},
{0xd0e9, 0xfb83},
{0xd1e8, 0xfb84},
{0xd1ec, 0xfb87},
{0xd2bb, 0xfb88},
{0xd3e1, 0xfb8a},
{0xd3e8, 0xfb8b},
{0xd4a7, 0xfb8c},
{0xd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0xfbdd},
{0xe4dc, 0xfbdb},
{0xe4de, 0xfbd8},
{0xe4e0, 0xfbd7},
{0xe4e9, 0xfa5e},
{0xe4ef, 0xfbe0},
{0xe4fa, 0xfbdf},
{0xe5b3, 0xfbe1},
{0xe5bf, 0xfbe2},
{0xe5c9, 0xfbe3},
{0xe5d0, 0xfbe4},
{0xe5e2, 0xfbe5},
{0xe5ea, 0xfbe6},
{0xe5eb, 0xfbe7},
{0xe6e8, 0xfbeb},
{0xe6ef, 0xfbec},
{0xe7ac, 0xfbed},
{0xe7ae, 0xfbef},
{0xe7b1, 0xfbf1},
{0xe7b2, 0xfbf3},
{0xe8b1, 0xfbf4},
{0xe8b6, 0xfbf5},
{0xe8dd, 0xfbf8},
{0xe9d1, 0xfbfb},
{0xe9ed, 0xfc40},
{0xeacd, 0xfc41},
{0xeadb, 0xfc43},
{0xeae6, 0xfc44},
{0xeaea, 0xfc45},
{0xeba5, 0xfc46},
{0xebfa, 0xfc48},
{0xebfb, 0xfc47},
{0xecd6, 0xfc4a},
{0xf3f3, 0xfa40},
{0xf3f4, 0xfa41},
{0xf3f5, 0xfa42},
{0xf3f6, 0xfa43},
{0xf3f7, 0xfa44},
{0xf3f8, 0xfa45},
{0xf3f9, 0xfa46},
{0xf3fa, 0xfa47},
{0xf3fb, 0xfa48},
{0xf3fc, 0xfa49},
{0xf3fd, 0xfa4a},
{0xf3fe, 0xfa4b},
{0xf4a1, 0xfa4c},
{0xf4a2, 0xfa4d},
{0xf4a3, 0xfa4e},
{0xf4a4, 0xfa4f},
{0xf4a5, 0xfa50},
{0xf4a6, 0xfa51},
{0xf4a7, 0xfa52},
{0xf4a8, 0xfa53},
{0xf4a9, 0xfa56},
{0xf4aa, 0xfa57},
{0xf4ab, 0xfa58},
{0xf4ac, 0xfa59},
{0xf4ad, 0xfa5a},
{0xf4ae, 0xfa62},
{0xf4af, 0xfa6a},
{0xf4b0, 0xfa7c},
{0xf4b1, 0xfa83},
{0xf4b2, 0xfa8a},
{0xf4b3, 0xfa8b},
{0xf4b4, 0xfa90},
{0xf4b5, 0xfa92},
{0xf4b6, 0xfa96},
{0xf4b7, 0xfa9b},
{0xf4b8, 0xfa9c},
{0xf4b9, 0xfa9d},
{0xf4ba, 0xfaaa},
{0xf4bb, 0xfaae},
{0xf4bc, 0xfab0},
{0xf4bd, 0xfab1},
{0xf4be, 0xfaba},
{0xf4bf, 0xfabd},
{0xf4c0, 0xfac1},
{0xf4c1, 0xfacd},
{0xf4c2, 0xfad0},
{0xf4c3, 0xfad5},
{0xf4c4, 0xfad8},
{0xf4c5, 0xfae0},
{0xf4c6, 0xfae5},
{0xf4c7, 0xfae8},
{0xf4c8, 0xfaea},
{0xf4c9, 0xfaee},
{0xf4ca, 0xfaf2},
{0xf4cb, 0xfb43},
{0xf4cc, 0xfb44},
{0xf4cd, 0xfb50},
{0xf4ce, 0xfb58},
{0xf4cf, 0xfb5e},
{0xf4d0, 0xfb6e},
{0xf4d1, 0xfb70},
{0xf4d2, 0xfb72},
{0xf4d3, 0xfb75},
{0xf4d4, 0xfb7c},
{0xf4d5, 0xfb7d},
{0xf4d6, 0xfb7e},
{0xf4d7, 0xfb80},
{0xf4d8, 0xfb82},
{0xf4d9, 0xfb85},
{0xf4da, 0xfb86},
{0xf4db, 0xfb89},
{0xf4dc, 0xfb8d},
{0xf4dd, 0xfb8e},
{0xf4de, 0xfb92},
{0xf4df, 0xfb94},
{0xf4e0, 0xfb9d},
{0xf4e1, 0xfb9e},
{0xf4e2, 0xfb9f},
{0xf4e3, 0xfba0},
{0xf4e4, 0xfba1},
{0xf4e5, 0xfba9},
{0xf4e6, 0xfbac},
{0xf4e7, 0xfbae},
{0xf4e8, 0xfbb0},
{0xf4e9, 0xfbb1},
{0xf4ea, 0xfbb3},
{0xf4eb, 0xfbb4},
{0xf4ec, 0xfbb6},
{0xf4ed, 0xfbb7},
{0xf4ee, 0xfbb8},
{0xf4ef, 0xfbd3},
{0xf4f0, 0xfbda},
{0xf4f1, 0xfbe8},
{0xf4f2, 0xfbe9},
{0xf4f3, 0xfbea},
{0xf4f4, 0xfbee},
{0xf4f5, 0xfbf0},
{0xf4f6, 0xfbf2},
{0xf4f7, 0xfbf6},
{0xf4f8, 0xfbf7},
{0xf4f9, 0xfbf9},
{0xf4fa, 0xfbfa},
{0xf4fb, 0xfbfc},
{0xf4fc, 0xfc42},
{0xf4fd, 0xfc49},
{0xf4fe, 0xfc4b},
};

#define	EUC3REVTBLSIZ	(sizeof(euc3rev) / sizeof(sjis_euc_revmap_t))

#endif /* _KANJI_C_ */
#endif /* _KANJI_H_ */