1
/**********************************************************************
3
**********************************************************************/
5
* Copyright (c) 2002-2004 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
8
* Redistribution and use in source and binary forms, with or without
9
* modification, are permitted provided that the following conditions
11
* 1. Redistributions of source code must retain the above copyright
12
* notice, this list of conditions and the following disclaimer.
13
* 2. Redistributions in binary form must reproduce the above copyright
14
* notice, this list of conditions and the following disclaimer in the
15
* documentation and/or other materials provided with the distribution.
17
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35
#define UNICODE_ISO_8859_1 0
45
#define ISO_8859_10 10
46
#define ISO_8859_11 11
47
#define ISO_8859_13 12
48
#define ISO_8859_14 13
49
#define ISO_8859_15 14
50
#define ISO_8859_16 15
59
static ENC_INFO Info[] = {
60
{ UNICODE_ISO_8859_1, "UNICODE_ISO_8859_1" },
61
{ ISO_8859_1, "ISO_8859_1" },
62
{ ISO_8859_2, "ISO_8859_2" },
63
{ ISO_8859_3, "ISO_8859_3" },
64
{ ISO_8859_4, "ISO_8859_4" },
65
{ ISO_8859_5, "ISO_8859_5" },
66
{ ISO_8859_6, "ISO_8859_6" },
67
{ ISO_8859_7, "ISO_8859_7" },
68
{ ISO_8859_8, "ISO_8859_8" },
69
{ ISO_8859_9, "ISO_8859_9" },
70
{ ISO_8859_10, "ISO_8859_10" },
71
{ ISO_8859_11, "ISO_8859_11" },
72
{ ISO_8859_13, "ISO_8859_13" },
73
{ ISO_8859_14, "ISO_8859_14" },
74
{ ISO_8859_15, "ISO_8859_15" },
75
{ ISO_8859_16, "ISO_8859_16" },
81
static int IsAlpha(int enc, int c)
83
if (c >= 0x41 && c <= 0x5a) return 1;
84
if (c >= 0x61 && c <= 0x7a) return 1;
87
case UNICODE_ISO_8859_1:
90
if (c == 0xaa) return 1;
91
if (c == 0xb5) return 1;
92
if (c == 0xba) return 1;
93
if (c >= 0xc0 && c <= 0xd6) return 1;
94
if (c >= 0xd8 && c <= 0xf6) return 1;
95
if (c >= 0xf8 && c <= 0xff) return 1;
99
if (c == 0xa1 || c == 0xa3) return 1;
100
if (c == 0xa5 || c == 0xa6) return 1;
101
if (c >= 0xa9 && c <= 0xac) return 1;
102
if (c >= 0xae && c <= 0xaf) return 1;
103
if (c == 0xb1 || c == 0xb3) return 1;
104
if (c == 0xb5 || c == 0xb6) return 1;
105
if (c >= 0xb9 && c <= 0xbc) return 1;
106
if (c >= 0xbe && c <= 0xbf) return 1;
107
if (c >= 0xc0 && c <= 0xd6) return 1;
108
if (c >= 0xd8 && c <= 0xf6) return 1;
109
if (c >= 0xf8 && c <= 0xfe) return 1;
113
if (c == 0xa1) return 1;
114
if (c == 0xa6) return 1;
115
if (c >= 0xa9 && c <= 0xac) return 1;
116
if (c == 0xaf) return 1;
117
if (c == 0xb1) return 1;
118
if (c == 0xb5 || c == 0xb6) return 1;
119
if (c >= 0xb9 && c <= 0xbc) return 1;
120
if (c == 0xbf) return 1;
121
if (c >= 0xc0 && c <= 0xc2) return 1;
122
if (c >= 0xc4 && c <= 0xcf) return 1;
123
if (c >= 0xd1 && c <= 0xd6) return 1;
124
if (c >= 0xd8 && c <= 0xe2) return 1;
125
if (c >= 0xe4 && c <= 0xef) return 1;
126
if (c >= 0xf1 && c <= 0xf6) return 1;
127
if (c >= 0xf8 && c <= 0xfe) return 1;
131
if (c >= 0xa1 && c <= 0xa3) return 1;
132
if (c == 0xa5 || c == 0xa6) return 1;
133
if (c >= 0xa9 && c <= 0xac) return 1;
134
if (c == 0xae) return 1;
135
if (c == 0xb1 || c == 0xb3) return 1;
136
if (c == 0xb5 || c == 0xb6) return 1;
137
if (c >= 0xb9 && c <= 0xbf) return 1;
138
if (c >= 0xc0 && c <= 0xd6) return 1;
139
if (c >= 0xd8 && c <= 0xf6) return 1;
140
if (c >= 0xf8 && c <= 0xfe) return 1;
144
if (c >= 0xa1 && c <= 0xcf && c != 0xad) return 1;
145
if (c >= 0xd0 && c <= 0xff && c != 0xf0 && c != 0xfd) return 1;
149
if (c >= 0xc1 && c <= 0xda) return 1;
150
if (c >= 0xe0 && c <= 0xf2) return 1;
154
if (c == 0xb6) return 1;
155
if (c >= 0xb8 && c <= 0xba) return 1;
156
if (c == 0xbc) return 1;
157
if (c >= 0xbe && c <= 0xbf) return 1;
158
if (c == 0xc0) return 1;
159
if (c >= 0xc1 && c <= 0xdb && c != 0xd2) return 1;
160
if (c >= 0xdc && c <= 0xfe) return 1;
164
if (c == 0xb5) return 1;
165
if (c >= 0xe0 && c <= 0xfa) return 1;
169
if (c >= 0xa1 && c <= 0xa6) return 1;
170
if (c >= 0xa8 && c <= 0xac) return 1;
171
if (c == 0xae || c == 0xaf) return 1;
172
if (c >= 0xb1 && c <= 0xb6) return 1;
173
if (c >= 0xb8 && c <= 0xbc) return 1;
174
if (c >= 0xbe && c <= 0xff) return 1;
178
if (c >= 0xa1 && c <= 0xda) return 1;
179
if (c >= 0xdf && c <= 0xfb) return 1;
183
if (c == 0xa8) return 1;
184
if (c == 0xaa) return 1;
185
if (c == 0xaf) return 1;
186
if (c == 0xb5) return 1;
187
if (c == 0xb8) return 1;
188
if (c == 0xba) return 1;
189
if (c >= 0xbf && c <= 0xd6) return 1;
190
if (c >= 0xd8 && c <= 0xf6) return 1;
191
if (c >= 0xf8 && c <= 0xfe) return 1;
195
if (c == 0xa1 || c == 0xa2) return 1;
196
if (c == 0xa4 || c == 0xa5) return 1;
197
if (c == 0xa6 || c == 0xa8) return 1;
198
if (c >= 0xaa && c <= 0xac) return 1;
199
if (c >= 0xaf && c <= 0xb5) return 1;
200
if (c >= 0xb7 && c <= 0xff) return 1;
204
if (c == 0xaa) return 1;
205
if (c == 0xb5) return 1;
206
if (c == 0xba) return 1;
207
if (c >= 0xc0 && c <= 0xd6) return 1;
208
if (c >= 0xd8 && c <= 0xf6) return 1;
209
if (c >= 0xf8 && c <= 0xff) return 1;
210
if (c == 0xa6) return 1;
211
if (c == 0xa8) return 1;
212
if (c == 0xb4) return 1;
213
if (c == 0xb8) return 1;
214
if (c == 0xbc) return 1;
215
if (c == 0xbd) return 1;
216
if (c == 0xbe) return 1;
220
if (c == 0xa1) return 1;
221
if (c == 0xa2) return 1;
222
if (c == 0xa3) return 1;
223
if (c == 0xa6) return 1;
224
if (c == 0xa8) return 1;
225
if (c == 0xaa) return 1;
226
if (c == 0xac) return 1;
227
if (c == 0xae) return 1;
228
if (c == 0xaf) return 1;
229
if (c == 0xb2) return 1;
230
if (c == 0xb3) return 1;
231
if (c == 0xb4) return 1;
232
if (c >= 0xb8 && c <= 0xba) return 1;
233
if (c == 0xbc) return 1;
234
if (c == 0xbd) return 1;
235
if (c == 0xbe) return 1;
236
if (c == 0xbf) return 1;
237
if (c >= 0xc0 && c <= 0xde) return 1;
238
if (c >= 0xdf && c <= 0xff) return 1;
242
if (c == 0xa3 || c == 0xb3) return 1;
245
if (c >= 0xc0 && c <= 0xff) return 1;
255
static int IsBlank(int enc, int c)
257
if (c == 0x09 || c == 0x20) return 1;
260
case UNICODE_ISO_8859_1:
277
if (c == 0xa0) return 1;
281
if (c == 0x9a) return 1;
291
static int IsCntrl(int enc, int c)
293
if (c >= 0x00 && c <= 0x1F) return 1;
296
case UNICODE_ISO_8859_1:
297
if (c == 0xad) return 1;
315
if (c >= 0x7f && c <= 0x9F) return 1;
320
if (c == 0x7f) return 1;
330
static int IsDigit(int enc, int c)
332
if (c >= 0x30 && c <= 0x39) return 1;
336
static int IsGraph(int enc, int c)
338
if (c >= 0x21 && c <= 0x7e) return 1;
341
case UNICODE_ISO_8859_1:
352
if (c >= 0xa1 && c <= 0xff) return 1;
357
if (c == 0xa5 || c == 0xae || c == 0xbe || c == 0xc3 || c == 0xd0 ||
358
c == 0xe3 || c == 0xf0)
366
if (c == 0xa4 || c == 0xac || c == 0xad || c == 0xbb || c == 0xbf)
368
if (c >= 0xc1 && c <= 0xda) return 1;
369
if (c >= 0xe0 && c <= 0xf2) return 1;
373
if (c >= 0xa1 && c <= 0xfe &&
374
c != 0xa4 && c != 0xa5 && c != 0xaa &&
375
c != 0xae && c != 0xd2) return 1;
379
if (c >= 0xa2 && c <= 0xfa) {
380
if (c >= 0xbf && c <= 0xde) return 0;
386
if (c >= 0xa1 && c <= 0xda) return 1;
387
if (c >= 0xdf && c <= 0xfb) return 1;
391
if (c >= 0xc0 && c <= 0xff) return 1;
395
if (c >= 0x80 && c <= 0xff && c != 0x9a) return 1;
405
static int IsLower(int enc, int c)
407
if (c >= 0x61 && c <= 0x7a) return 1;
410
case UNICODE_ISO_8859_1:
413
if (c == 0xaa) return 1;
414
if (c == 0xb5) return 1;
415
if (c == 0xba) return 1;
416
if (c >= 0xdf && c <= 0xf6) return 1;
417
if (c >= 0xf8 && c <= 0xff) return 1;
421
if (c == 0xb1 || c == 0xb3) return 1;
422
if (c == 0xb5 || c == 0xb6) return 1;
423
if (c >= 0xb9 && c <= 0xbc) return 1;
424
if (c >= 0xbe && c <= 0xbf) return 1;
425
if (c >= 0xdf && c <= 0xf6) return 1;
426
if (c >= 0xf8 && c <= 0xfe) return 1;
430
if (c == 0xb1) return 1;
431
if (c == 0xb5 || c == 0xb6) return 1;
432
if (c >= 0xb9 && c <= 0xbc) return 1;
433
if (c == 0xbf) return 1;
434
if (c == 0xdf) return 1;
435
if (c >= 0xe0 && c <= 0xe2) return 1;
436
if (c >= 0xe4 && c <= 0xef) return 1;
437
if (c >= 0xf1 && c <= 0xf6) return 1;
438
if (c >= 0xf8 && c <= 0xfe) return 1;
442
if (c == 0xa2) return 1;
443
if (c == 0xb1 || c == 0xb3) return 1;
444
if (c == 0xb5 || c == 0xb6) return 1;
445
if (c >= 0xb9 && c <= 0xbc) return 1;
446
if (c >= 0xbe && c <= 0xbf) return 1;
447
if (c == 0xdf) return 1;
448
if (c >= 0xe0 && c <= 0xf6) return 1;
449
if (c >= 0xf8 && c <= 0xfe) return 1;
453
if (c >= 0xd0 && c <= 0xff && c != 0xf0 && c != 0xfd) return 1;
460
if (c == 0xc0) return 1;
461
if (c >= 0xdc && c <= 0xfe) return 1;
465
if (c == 0xb5) return 1;
469
if (c >= 0xb1 && c <= 0xb6) return 1;
470
if (c >= 0xb8 && c <= 0xbc) return 1;
471
if (c == 0xbe || c == 0xbf) return 1;
472
if (c >= 0xdf && c <= 0xff) return 1;
479
if (c == 0xb5) return 1;
480
if (c == 0xb8) return 1;
481
if (c == 0xba) return 1;
482
if (c == 0xbf) return 1;
483
if (c >= 0xdf && c <= 0xf6) return 1;
484
if (c >= 0xf8 && c <= 0xfe) return 1;
488
if (c == 0xa2) return 1;
489
if (c == 0xa5) return 1;
490
if (c == 0xab) return 1;
491
if (c == 0xb1 || c == 0xb3 || c == 0xb5) return 1;
492
if (c >= 0xb8 && c <= 0xba) return 1;
493
if (c == 0xbc) return 1;
494
if (c == 0xbe || c == 0xbf) return 1;
495
if (c >= 0xdf && c <= 0xff) return 1;
499
if (c == 0xaa) return 1;
500
if (c == 0xb5) return 1;
501
if (c == 0xba) return 1;
502
if (c >= 0xdf && c <= 0xf6) return 1;
503
if (c >= 0xf8 && c <= 0xff) return 1;
504
if (c == 0xa8) return 1;
505
if (c == 0xb8) return 1;
506
if (c == 0xbd) return 1;
510
if (c == 0xa2) return 1;
511
if (c == 0xa8) return 1;
512
if (c == 0xae) return 1;
513
if (c == 0xb3) return 1;
514
if (c >= 0xb8 && c <= 0xba) return 1;
515
if (c == 0xbd) return 1;
516
if (c == 0xbf) return 1;
517
if (c >= 0xdf && c <= 0xff) return 1;
521
if (c == 0xa3) return 1;
524
if (c >= 0xc0 && c <= 0xdf) return 1;
534
static int IsPrint(int enc, int c)
536
if (c >= 0x20 && c <= 0x7e) return 1;
539
case UNICODE_ISO_8859_1:
540
if (c >= 0x09 && c <= 0x0d) return 1;
541
if (c == 0x85) return 1;
553
if (c >= 0xa0 && c <= 0xff) return 1;
558
if (c == 0xa5 || c == 0xae || c == 0xbe || c == 0xc3 || c == 0xd0 ||
559
c == 0xe3 || c == 0xf0)
567
if (c == 0xa0) return 1;
568
if (c == 0xa4 || c == 0xac || c == 0xad || c == 0xbb || c == 0xbf)
570
if (c >= 0xc1 && c <= 0xda) return 1;
571
if (c >= 0xe0 && c <= 0xf2) return 1;
575
if (c >= 0xa0 && c <= 0xfe &&
576
c != 0xa4 && c != 0xa5 && c != 0xaa &&
577
c != 0xae && c != 0xd2) return 1;
581
if (c >= 0xa0 && c <= 0xfa) {
582
if (c >= 0xbf && c <= 0xde) return 0;
583
if (c == 0xa1) return 0;
589
if (c >= 0xa0 && c <= 0xda) return 1;
590
if (c >= 0xdf && c <= 0xfb) return 1;
594
if (c == 0xa0) return 1;
595
if (c >= 0xc0 && c <= 0xff) return 1;
599
if (c >= 0x80 && c <= 0xff) return 1;
609
static int IsPunct(int enc, int c)
611
if (enc == UNICODE_ISO_8859_1) {
612
if (c == 0x24 || c == 0x2b || c == 0x5e || c == 0x60 ||
613
c == 0x7c || c == 0x7e) return 1;
614
if (c >= 0x3c && c <= 0x3e) return 1;
617
if (c >= 0x21 && c <= 0x23) return 1;
618
if (c >= 0x25 && c <= 0x2a) return 1;
619
if (c >= 0x2c && c <= 0x2f) return 1;
620
if (c >= 0x3a && c <= 0x3b) return 1;
621
if (c >= 0x3f && c <= 0x40) return 1;
622
if (c >= 0x5b && c <= 0x5d) return 1;
623
if (c == 0x5f) return 1;
624
if (c == 0x7b) return 1;
625
if (c == 0x7d) return 1;
631
if (c == 0xad) return 1;
633
case UNICODE_ISO_8859_1:
634
if (c == 0xa1) return 1;
635
if (c == 0xab) return 1;
636
if (c == 0xb7) return 1;
637
if (c == 0xbb) return 1;
638
if (c == 0xbf) return 1;
645
if (c == 0xad) return 1;
650
if (c == 0xad) return 1;
651
if (c == 0xb7) return 1;
652
if (c == 0xbd) return 1;
656
if (c == 0xac) return 1;
657
if (c == 0xad) return 1;
658
if (c == 0xbb) return 1;
659
if (c == 0xbf) return 1;
663
if (c == 0xa1 || c == 0xa2) return 1;
664
if (c == 0xab) return 1;
665
if (c == 0xaf) return 1;
666
if (c == 0xad) return 1;
667
if (c == 0xb7 || c == 0xbb) return 1;
671
if (c == 0xab) return 1;
672
if (c == 0xad) return 1;
673
if (c == 0xb7) return 1;
674
if (c == 0xbb) return 1;
675
if (c == 0xdf) return 1;
679
if (c == 0xa1 || c == 0xa5) return 1;
680
if (c == 0xab || c == 0xad) return 1;
681
if (c == 0xb4 || c == 0xb7) return 1;
682
if (c == 0xbb) return 1;
683
if (c == 0xff) return 1;
687
if (c == 0xa5) return 1;
688
if (c == 0xab) return 1;
689
if (c == 0xad) return 1;
690
if (c == 0xb5) return 1;
691
if (c == 0xb7) return 1;
692
if (c == 0xbb) return 1;
696
if (c == 0x9e) return 1;
710
static int IsSpace(int enc, int c)
712
if (c >= 0x09 && c <= 0x0d) return 1;
713
if (c == 0x20) return 1;
716
case UNICODE_ISO_8859_1:
717
if (c == 0x85) return 1;
735
if (c == 0xa0) return 1;
739
if (c == 0x9a) return 1;
749
static int IsUpper(int enc, int c)
751
if (c >= 0x41 && c <= 0x5a) return 1;
754
case UNICODE_ISO_8859_1:
757
if (c >= 0xc0 && c <= 0xd6) return 1;
758
if (c >= 0xd8 && c <= 0xde) return 1;
762
if (c == 0xa1 || c == 0xa3) return 1;
763
if (c == 0xa5 || c == 0xa6) return 1;
764
if (c >= 0xa9 && c <= 0xac) return 1;
765
if (c >= 0xae && c <= 0xaf) return 1;
766
if (c >= 0xc0 && c <= 0xd6) return 1;
767
if (c >= 0xd8 && c <= 0xde) return 1;
771
if (c == 0xa1) return 1;
772
if (c == 0xa6) return 1;
773
if (c >= 0xa9 && c <= 0xac) return 1;
774
if (c == 0xaf) return 1;
775
if (c >= 0xc0 && c <= 0xc2) return 1;
776
if (c >= 0xc4 && c <= 0xcf) return 1;
777
if (c >= 0xd1 && c <= 0xd6) return 1;
778
if (c >= 0xd8 && c <= 0xde) return 1;
782
if (c == 0xa1 || c == 0xa3) return 1;
783
if (c == 0xa5 || c == 0xa6) return 1;
784
if (c >= 0xa9 && c <= 0xac) return 1;
785
if (c == 0xae) return 1;
786
if (c == 0xbd) return 1;
787
if (c >= 0xc0 && c <= 0xd6) return 1;
788
if (c >= 0xd8 && c <= 0xde) return 1;
792
if (c >= 0xa1 && c <= 0xcf && c != 0xad) return 1;
799
if (c == 0xb6) return 1;
800
if (c >= 0xb8 && c <= 0xba) return 1;
801
if (c == 0xbc) return 1;
802
if (c >= 0xbe && c <= 0xbf) return 1;
803
if (c >= 0xc1 && c <= 0xdb && c != 0xd2) return 1;
811
if (c >= 0xa1 && c <= 0xa6) return 1;
812
if (c >= 0xa8 && c <= 0xac) return 1;
813
if (c == 0xae || c == 0xaf) return 1;
814
if (c >= 0xc0 && c <= 0xde) return 1;
818
if (c == 0xa8) return 1;
819
if (c == 0xaa) return 1;
820
if (c == 0xaf) return 1;
821
if (c >= 0xc0 && c <= 0xd6) return 1;
822
if (c >= 0xd8 && c <= 0xde) return 1;
826
if (c == 0xa1) return 1;
827
if (c == 0xa4 || c == 0xa6) return 1;
828
if (c == 0xa8) return 1;
829
if (c == 0xaa || c == 0xac) return 1;
830
if (c == 0xaf || c == 0xb0) return 1;
831
if (c == 0xb2 || c == 0xb4 || c == 0xb7) return 1;
832
if (c == 0xbb || c == 0xbd) return 1;
833
if (c >= 0xc0 && c <= 0xde) return 1;
837
if (c >= 0xc0 && c <= 0xd6) return 1;
838
if (c >= 0xd8 && c <= 0xde) return 1;
839
if (c == 0xa6) return 1;
840
if (c == 0xb4) return 1;
841
if (c == 0xbc) return 1;
842
if (c == 0xbe) return 1;
846
if (c == 0xa1) return 1;
847
if (c == 0xa3) return 1;
848
if (c == 0xa6) return 1;
849
if (c == 0xaa) return 1;
850
if (c == 0xac) return 1;
851
if (c == 0xaf) return 1;
852
if (c == 0xb2) return 1;
853
if (c == 0xb4) return 1;
854
if (c == 0xbc) return 1;
855
if (c == 0xbe) return 1;
856
if (c >= 0xc0 && c <= 0xde) return 1;
860
if (c == 0xb3) return 1;
863
if (c >= 0xe0 && c <= 0xff) return 1;
873
static int IsXDigit(int enc, int c)
875
if (c >= 0x30 && c <= 0x39) return 1;
876
if (c >= 0x41 && c <= 0x46) return 1;
877
if (c >= 0x61 && c <= 0x66) return 1;
881
static int IsWord(int enc, int c)
883
if (c >= 0x30 && c <= 0x39) return 1;
884
if (c >= 0x41 && c <= 0x5a) return 1;
885
if (c == 0x5f) return 1;
886
if (c >= 0x61 && c <= 0x7a) return 1;
889
case UNICODE_ISO_8859_1:
892
if (c == 0xaa) return 1;
893
if (c >= 0xb2 && c <= 0xb3) return 1;
894
if (c == 0xb5) return 1;
895
if (c >= 0xb9 && c <= 0xba) return 1;
896
if (c >= 0xbc && c <= 0xbe) return 1;
897
if (c >= 0xc0 && c <= 0xd6) return 1;
898
if (c >= 0xd8 && c <= 0xf6) return 1;
899
if (c >= 0xf8 && c <= 0xff) return 1;
903
if (c == 0xa1 || c == 0xa3) return 1;
904
if (c == 0xa5 || c == 0xa6) return 1;
905
if (c >= 0xa9 && c <= 0xac) return 1;
906
if (c >= 0xae && c <= 0xaf) return 1;
907
if (c == 0xb1 || c == 0xb3) return 1;
908
if (c == 0xb5 || c == 0xb6) return 1;
909
if (c >= 0xb9 && c <= 0xbc) return 1;
910
if (c >= 0xbe && c <= 0xbf) return 1;
911
if (c >= 0xc0 && c <= 0xd6) return 1;
912
if (c >= 0xd8 && c <= 0xf6) return 1;
913
if (c >= 0xf8 && c <= 0xfe) return 1;
917
if (c == 0xa1) return 1;
918
if (c == 0xa6) return 1;
919
if (c >= 0xa9 && c <= 0xac) return 1;
920
if (c == 0xaf) return 1;
921
if (c >= 0xb1 && c <= 0xb3) return 1;
922
if (c == 0xb5 || c == 0xb6) return 1;
923
if (c >= 0xb9 && c <= 0xbd) return 1;
924
if (c == 0xbf) return 1;
925
if (c >= 0xc0 && c <= 0xc2) return 1;
926
if (c >= 0xc4 && c <= 0xcf) return 1;
927
if (c >= 0xd1 && c <= 0xd6) return 1;
928
if (c >= 0xd8 && c <= 0xe2) return 1;
929
if (c >= 0xe4 && c <= 0xef) return 1;
930
if (c >= 0xf1 && c <= 0xf6) return 1;
931
if (c >= 0xf8 && c <= 0xfe) return 1;
935
if (c >= 0xa1 && c <= 0xa3) return 1;
936
if (c == 0xa5 || c == 0xa6) return 1;
937
if (c >= 0xa9 && c <= 0xac) return 1;
938
if (c == 0xae) return 1;
939
if (c == 0xb1 || c == 0xb3) return 1;
940
if (c == 0xb5 || c == 0xb6) return 1;
941
if (c >= 0xb9 && c <= 0xbf) return 1;
942
if (c >= 0xc0 && c <= 0xd6) return 1;
943
if (c >= 0xd8 && c <= 0xf6) return 1;
944
if (c >= 0xf8 && c <= 0xfe) return 1;
948
if (c >= 0xa1 && c <= 0xcf && c != 0xad) return 1;
949
if (c >= 0xd0 && c <= 0xff && c != 0xf0 && c != 0xfd) return 1;
953
if (c >= 0xc1 && c <= 0xda) return 1;
954
if (c >= 0xe0 && c <= 0xea) return 1;
955
if (c >= 0xeb && c <= 0xf2) return 1;
959
if (c == 0xb2 || c == 0xb3) return 1;
960
if (c == 0xb6) return 1;
961
if (c >= 0xb8 && c <= 0xba) return 1;
962
if (c >= 0xbc && c <= 0xbf) return 1;
963
if (c == 0xc0) return 1;
964
if (c >= 0xc1 && c <= 0xdb && c != 0xd2) return 1;
965
if (c >= 0xdc && c <= 0xfe) return 1;
969
if (c == 0xb2 || c == 0xb3 || c == 0xb5 || c == 0xb9) return 1;
970
if (c >= 0xbc && c <= 0xbe) return 1;
971
if (c >= 0xe0 && c <= 0xfa) return 1;
975
if (c >= 0xa1 && c <= 0xff) {
976
if (c != 0xa7 && c != 0xad && c != 0xb0 && c != 0xb7 && c != 0xbd)
982
if (c >= 0xa1 && c <= 0xda) return 1;
983
if (c >= 0xdf && c <= 0xfb) return 1;
987
if (c == 0xa8) return 1;
988
if (c == 0xaa) return 1;
989
if (c == 0xaf) return 1;
990
if (c == 0xb2 || c == 0xb3 || c == 0xb5 || c == 0xb9) return 1;
991
if (c >= 0xbc && c <= 0xbe) return 1;
992
if (c == 0xb8) return 1;
993
if (c == 0xba) return 1;
994
if (c >= 0xbf && c <= 0xd6) return 1;
995
if (c >= 0xd8 && c <= 0xf6) return 1;
996
if (c >= 0xf8 && c <= 0xfe) return 1;
1000
if (c >= 0xa1 && c <= 0xff) {
1001
if (c == 0xa3 || c == 0xa7 || c == 0xa9 || c == 0xad || c == 0xae ||
1002
c == 0xb6) return 0;
1008
if (c == 0xaa) return 1;
1009
if (c >= 0xb2 && c <= 0xb3) return 1;
1010
if (c == 0xb5) return 1;
1011
if (c >= 0xb9 && c <= 0xba) return 1;
1012
if (c >= 0xbc && c <= 0xbe) return 1;
1013
if (c >= 0xc0 && c <= 0xd6) return 1;
1014
if (c >= 0xd8 && c <= 0xf6) return 1;
1015
if (c >= 0xf8 && c <= 0xff) return 1;
1016
if (c == 0xa6) return 1;
1017
if (c == 0xa8) return 1;
1018
if (c == 0xb4) return 1;
1019
if (c == 0xb8) return 1;
1023
if (c == 0xa1) return 1;
1024
if (c == 0xa2) return 1;
1025
if (c == 0xa3) return 1;
1026
if (c == 0xa6) return 1;
1027
if (c == 0xa8) return 1;
1028
if (c == 0xaa) return 1;
1029
if (c == 0xac) return 1;
1030
if (c == 0xae) return 1;
1031
if (c == 0xaf) return 1;
1032
if (c == 0xb2) return 1;
1033
if (c == 0xb3) return 1;
1034
if (c == 0xb4) return 1;
1035
if (c >= 0xb8 && c <= 0xba) return 1;
1036
if (c == 0xbc) return 1;
1037
if (c == 0xbd) return 1;
1038
if (c == 0xbe) return 1;
1039
if (c == 0xbf) return 1;
1040
if (c >= 0xc0 && c <= 0xde) return 1;
1041
if (c >= 0xdf && c <= 0xff) return 1;
1045
if (c == 0x9d) return 1;
1046
if (c == 0xa3 || c == 0xb3) return 1;
1049
if (c >= 0xc0 && c <= 0xff) return 1;
1059
static int IsAscii(int enc, int c)
1061
if (c >= 0x00 && c <= 0x7f) return 1;
1065
static int IsNewline(int enc, int c)
1067
if (c == 0x0a) return 1;
1071
static int exec(FILE* fp, ENC_INFO* einfo)
1079
fprintf(fp, "static unsigned short Enc%s_CtypeTable[256] = {\n",
1082
for (c = 0; c < 256; c++) {
1084
if (IsNewline(enc, c)) val |= ONIGENC_CTYPE_NEWLINE;
1085
if (IsAlpha (enc, c)) val |= ONIGENC_CTYPE_ALPHA;
1086
if (IsBlank (enc, c)) val |= ONIGENC_CTYPE_BLANK;
1087
if (IsCntrl (enc, c)) val |= ONIGENC_CTYPE_CNTRL;
1088
if (IsDigit (enc, c)) val |= ONIGENC_CTYPE_DIGIT;
1089
if (IsGraph (enc, c)) val |= ONIGENC_CTYPE_GRAPH;
1090
if (IsLower (enc, c)) val |= ONIGENC_CTYPE_LOWER;
1091
if (IsPrint (enc, c)) val |= ONIGENC_CTYPE_PRINT;
1092
if (IsPunct (enc, c)) val |= ONIGENC_CTYPE_PUNCT;
1093
if (IsSpace (enc, c)) val |= ONIGENC_CTYPE_SPACE;
1094
if (IsUpper (enc, c)) val |= ONIGENC_CTYPE_UPPER;
1095
if (IsXDigit(enc, c)) val |= ONIGENC_CTYPE_XDIGIT;
1096
if (IsWord (enc, c)) val |= ONIGENC_CTYPE_WORD;
1097
if (IsAscii (enc, c)) val |= ONIGENC_CTYPE_ASCII;
1099
if (c % NCOL == 0) fputs(" ", fp);
1100
fprintf(fp, "0x%04x", val);
1101
if (c != 255) fputs(",", fp);
1102
if (c != 0 && c % NCOL == (NCOL-1))
1107
fprintf(fp, "};\n");
1111
extern int main(int argc, char* argv[])
1116
for (i = 0; i < sizeof(Info)/sizeof(ENC_INFO); i++) {