xref: /netbsd-src/external/gpl2/xcvs/dist/lib/mbchar.h (revision a7c918477dd5f12c1da816ba05caf44eab2d06d6)
1*a7c91847Schristos /* Multibyte character data type.
2*a7c91847Schristos    Copyright (C) 2001, 2005 Free Software Foundation, Inc.
3*a7c91847Schristos 
4*a7c91847Schristos    This program is free software; you can redistribute it and/or modify
5*a7c91847Schristos    it under the terms of the GNU General Public License as published by
6*a7c91847Schristos    the Free Software Foundation; either version 2, or (at your option)
7*a7c91847Schristos    any later version.
8*a7c91847Schristos 
9*a7c91847Schristos    This program is distributed in the hope that it will be useful,
10*a7c91847Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
11*a7c91847Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12*a7c91847Schristos    GNU General Public License for more details.
13*a7c91847Schristos 
14*a7c91847Schristos    You should have received a copy of the GNU General Public License
15*a7c91847Schristos    along with this program; if not, write to the Free Software Foundation,
16*a7c91847Schristos    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
17*a7c91847Schristos 
18*a7c91847Schristos /* Written by Bruno Haible <bruno@clisp.org>.  */
19*a7c91847Schristos 
20*a7c91847Schristos /* A multibyte character is a short subsequence of a char* string,
21*a7c91847Schristos    representing a single wide character.
22*a7c91847Schristos 
23*a7c91847Schristos    We use multibyte characters instead of wide characters because of
24*a7c91847Schristos    the following goals:
25*a7c91847Schristos    1) correct multibyte handling, i.e. operate according to the LC_CTYPE
26*a7c91847Schristos       locale,
27*a7c91847Schristos    2) ease of maintenance, i.e. the maintainer needs not know all details
28*a7c91847Schristos       of the ISO C 99 standard,
29*a7c91847Schristos    3) don't fail grossly if the input is not in the encoding set by the
30*a7c91847Schristos       locale, because often different encodings are in use in the same
31*a7c91847Schristos       countries (ISO-8859-1/UTF-8, EUC-JP/Shift_JIS, ...),
32*a7c91847Schristos    4) fast in the case of ASCII characters,
33*a7c91847Schristos    5) portability, i.e. don't make unportable assumptions about wchar_t.
34*a7c91847Schristos 
35*a7c91847Schristos    Multibyte characters are only accessed through the mb* macros.
36*a7c91847Schristos 
37*a7c91847Schristos    mb_ptr (mbc)
38*a7c91847Schristos      return a pointer to the beginning of the multibyte sequence.
39*a7c91847Schristos 
40*a7c91847Schristos    mb_len (mbc)
41*a7c91847Schristos      returns the number of bytes occupied by the multibyte sequence.
42*a7c91847Schristos      Always > 0.
43*a7c91847Schristos 
44*a7c91847Schristos    mb_iseq (mbc, sc)
45*a7c91847Schristos      returns true if mbc is the standard ASCII character sc.
46*a7c91847Schristos 
47*a7c91847Schristos    mb_isnul (mbc)
48*a7c91847Schristos      returns true if mbc is the nul character.
49*a7c91847Schristos 
50*a7c91847Schristos    mb_cmp (mbc1, mbc2)
51*a7c91847Schristos      returns a positive, zero, or negative value depending on whether mbc1
52*a7c91847Schristos      sorts after, same or before mbc2.
53*a7c91847Schristos 
54*a7c91847Schristos    mb_casecmp (mbc1, mbc2)
55*a7c91847Schristos      returns a positive, zero, or negative value depending on whether mbc1
56*a7c91847Schristos      sorts after, same or before mbc2, modulo upper/lowercase conversion.
57*a7c91847Schristos 
58*a7c91847Schristos    mb_equal (mbc1, mbc2)
59*a7c91847Schristos      returns true if mbc1 and mbc2 are equal.
60*a7c91847Schristos 
61*a7c91847Schristos    mb_caseequal (mbc1, mbc2)
62*a7c91847Schristos      returns true if mbc1 and mbc2 are equal modulo upper/lowercase conversion.
63*a7c91847Schristos 
64*a7c91847Schristos    mb_isalnum (mbc)
65*a7c91847Schristos      returns true if mbc is alphanumeric.
66*a7c91847Schristos 
67*a7c91847Schristos    mb_isalpha (mbc)
68*a7c91847Schristos      returns true if mbc is alphabetic.
69*a7c91847Schristos 
70*a7c91847Schristos    mb_isascii(mbc)
71*a7c91847Schristos      returns true if mbc is plain ASCII.
72*a7c91847Schristos 
73*a7c91847Schristos    mb_isblank (mbc)
74*a7c91847Schristos      returns true if mbc is a blank.
75*a7c91847Schristos 
76*a7c91847Schristos    mb_iscntrl (mbc)
77*a7c91847Schristos      returns true if mbc is a control character.
78*a7c91847Schristos 
79*a7c91847Schristos    mb_isdigit (mbc)
80*a7c91847Schristos      returns true if mbc is a decimal digit.
81*a7c91847Schristos 
82*a7c91847Schristos    mb_isgraph (mbc)
83*a7c91847Schristos      returns true if mbc is a graphic character.
84*a7c91847Schristos 
85*a7c91847Schristos    mb_islower (mbc)
86*a7c91847Schristos      returns true if mbc is lowercase.
87*a7c91847Schristos 
88*a7c91847Schristos    mb_isprint (mbc)
89*a7c91847Schristos      returns true if mbc is a printable character.
90*a7c91847Schristos 
91*a7c91847Schristos    mb_ispunct (mbc)
92*a7c91847Schristos      returns true if mbc is a punctuation character.
93*a7c91847Schristos 
94*a7c91847Schristos    mb_isspace (mbc)
95*a7c91847Schristos      returns true if mbc is a space character.
96*a7c91847Schristos 
97*a7c91847Schristos    mb_isupper (mbc)
98*a7c91847Schristos      returns true if mbc is uppercase.
99*a7c91847Schristos 
100*a7c91847Schristos    mb_isxdigit (mbc)
101*a7c91847Schristos      returns true if mbc is a hexadecimal digit.
102*a7c91847Schristos 
103*a7c91847Schristos    mb_width (mbc)
104*a7c91847Schristos      returns the number of columns on the output device occupied by mbc.
105*a7c91847Schristos      Always >= 0.
106*a7c91847Schristos 
107*a7c91847Schristos    mb_putc (mbc, stream)
108*a7c91847Schristos      outputs mbc on stream, a byte oriented FILE stream opened for output.
109*a7c91847Schristos 
110*a7c91847Schristos    mb_setascii (&mbc, sc)
111*a7c91847Schristos      assigns the standard ASCII character sc to mbc.
112*a7c91847Schristos 
113*a7c91847Schristos    mb_copy (&destmbc, &srcmbc)
114*a7c91847Schristos      copies srcmbc to destmbc.
115*a7c91847Schristos 
116*a7c91847Schristos    Here are the function prototypes of the macros.
117*a7c91847Schristos 
118*a7c91847Schristos    extern const char *	mb_ptr (const mbchar_t mbc);
119*a7c91847Schristos    extern size_t	mb_len (const mbchar_t mbc);
120*a7c91847Schristos    extern bool		mb_iseq (const mbchar_t mbc, char sc);
121*a7c91847Schristos    extern bool		mb_isnul (const mbchar_t mbc);
122*a7c91847Schristos    extern int		mb_cmp (const mbchar_t mbc1, const mbchar_t mbc2);
123*a7c91847Schristos    extern int		mb_casecmp (const mbchar_t mbc1, const mbchar_t mbc2);
124*a7c91847Schristos    extern bool		mb_equal (const mbchar_t mbc1, const mbchar_t mbc2);
125*a7c91847Schristos    extern bool		mb_caseequal (const mbchar_t mbc1, const mbchar_t mbc2);
126*a7c91847Schristos    extern bool		mb_isalnum (const mbchar_t mbc);
127*a7c91847Schristos    extern bool		mb_isalpha (const mbchar_t mbc);
128*a7c91847Schristos    extern bool		mb_isascii (const mbchar_t mbc);
129*a7c91847Schristos    extern bool		mb_isblank (const mbchar_t mbc);
130*a7c91847Schristos    extern bool		mb_iscntrl (const mbchar_t mbc);
131*a7c91847Schristos    extern bool		mb_isdigit (const mbchar_t mbc);
132*a7c91847Schristos    extern bool		mb_isgraph (const mbchar_t mbc);
133*a7c91847Schristos    extern bool		mb_islower (const mbchar_t mbc);
134*a7c91847Schristos    extern bool		mb_isprint (const mbchar_t mbc);
135*a7c91847Schristos    extern bool		mb_ispunct (const mbchar_t mbc);
136*a7c91847Schristos    extern bool		mb_isspace (const mbchar_t mbc);
137*a7c91847Schristos    extern bool		mb_isupper (const mbchar_t mbc);
138*a7c91847Schristos    extern bool		mb_isxdigit (const mbchar_t mbc);
139*a7c91847Schristos    extern int		mb_width (const mbchar_t mbc);
140*a7c91847Schristos    extern void		mb_putc (const mbchar_t mbc, FILE *stream);
141*a7c91847Schristos    extern void          mb_setascii (mbchar_t *new, char sc);
142*a7c91847Schristos    extern void		mb_copy (mbchar_t *new, const mbchar_t *old);
143*a7c91847Schristos  */
144*a7c91847Schristos 
145*a7c91847Schristos #ifndef _MBCHAR_H
146*a7c91847Schristos #define _MBCHAR_H 1
147*a7c91847Schristos 
148*a7c91847Schristos #include <stdbool.h>
149*a7c91847Schristos #include <string.h>
150*a7c91847Schristos 
151*a7c91847Schristos /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
152*a7c91847Schristos    <wchar.h>.
153*a7c91847Schristos    BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before
154*a7c91847Schristos    <wchar.h>.  */
155*a7c91847Schristos #include <stdio.h>
156*a7c91847Schristos #include <time.h>
157*a7c91847Schristos #include <wchar.h>
158*a7c91847Schristos 
159*a7c91847Schristos #include <wctype.h>
160*a7c91847Schristos 
161*a7c91847Schristos #define MBCHAR_BUF_SIZE 24
162*a7c91847Schristos 
163*a7c91847Schristos struct mbchar
164*a7c91847Schristos {
165*a7c91847Schristos   const char *ptr;	/* pointer to current character */
166*a7c91847Schristos   size_t bytes;		/* number of bytes of current character, > 0 */
167*a7c91847Schristos   bool wc_valid;	/* true if wc is a valid wide character */
168*a7c91847Schristos   wchar_t wc;		/* if wc_valid: the current character */
169*a7c91847Schristos   char buf[MBCHAR_BUF_SIZE]; /* room for the bytes, used for file input only */
170*a7c91847Schristos };
171*a7c91847Schristos 
172*a7c91847Schristos /* EOF (not a real character) is represented with bytes = 0 and
173*a7c91847Schristos    wc_valid = false.  */
174*a7c91847Schristos 
175*a7c91847Schristos typedef struct mbchar mbchar_t;
176*a7c91847Schristos 
177*a7c91847Schristos /* Access the current character.  */
178*a7c91847Schristos #define mb_ptr(mbc) ((mbc).ptr)
179*a7c91847Schristos #define mb_len(mbc) ((mbc).bytes)
180*a7c91847Schristos 
181*a7c91847Schristos /* Comparison of characters.  */
182*a7c91847Schristos #define mb_iseq(mbc, sc) ((mbc).wc_valid && (mbc).wc == (sc))
183*a7c91847Schristos #define mb_isnul(mbc) ((mbc).wc_valid && (mbc).wc == 0)
184*a7c91847Schristos #define mb_cmp(mbc1, mbc2) \
185*a7c91847Schristos   ((mbc1).wc_valid							\
186*a7c91847Schristos    ? ((mbc2).wc_valid							\
187*a7c91847Schristos       ? (int) (mbc1).wc - (int) (mbc2).wc				\
188*a7c91847Schristos       : -1)								\
189*a7c91847Schristos    : ((mbc2).wc_valid							\
190*a7c91847Schristos       ? 1								\
191*a7c91847Schristos       : (mbc1).bytes == (mbc2).bytes					\
192*a7c91847Schristos         ? memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes)			\
193*a7c91847Schristos         : (mbc1).bytes < (mbc2).bytes					\
194*a7c91847Schristos           ? (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) > 0 ? 1 : -1) \
195*a7c91847Schristos           : (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc2).bytes) >= 0 ? 1 : -1)))
196*a7c91847Schristos #define mb_casecmp(mbc1, mbc2) \
197*a7c91847Schristos   ((mbc1).wc_valid							\
198*a7c91847Schristos    ? ((mbc2).wc_valid							\
199*a7c91847Schristos       ? (int) towlower ((mbc1).wc) - (int) towlower ((mbc2).wc)		\
200*a7c91847Schristos       : -1)								\
201*a7c91847Schristos    : ((mbc2).wc_valid							\
202*a7c91847Schristos       ? 1								\
203*a7c91847Schristos       : (mbc1).bytes == (mbc2).bytes					\
204*a7c91847Schristos         ? memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes)			\
205*a7c91847Schristos         : (mbc1).bytes < (mbc2).bytes					\
206*a7c91847Schristos           ? (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) > 0 ? 1 : -1) \
207*a7c91847Schristos           : (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc2).bytes) >= 0 ? 1 : -1)))
208*a7c91847Schristos #define mb_equal(mbc1, mbc2) \
209*a7c91847Schristos   ((mbc1).wc_valid && (mbc2).wc_valid					\
210*a7c91847Schristos    ? (mbc1).wc == (mbc2).wc						\
211*a7c91847Schristos    : (mbc1).bytes == (mbc2).bytes					\
212*a7c91847Schristos      && memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) == 0)
213*a7c91847Schristos #define mb_caseequal(mbc1, mbc2) \
214*a7c91847Schristos   ((mbc1).wc_valid && (mbc2).wc_valid					\
215*a7c91847Schristos    ? towlower ((mbc1).wc) == towlower ((mbc2).wc)			\
216*a7c91847Schristos    : (mbc1).bytes == (mbc2).bytes					\
217*a7c91847Schristos      && memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) == 0)
218*a7c91847Schristos 
219*a7c91847Schristos /* <ctype.h>, <wctype.h> classification.  */
220*a7c91847Schristos #define mb_isascii(mbc) \
221*a7c91847Schristos   ((mbc).wc_valid && (mbc).wc >= 0 && (mbc).wc <= 127)
222*a7c91847Schristos #define mb_isalnum(mbc) ((mbc).wc_valid && iswalnum ((mbc).wc))
223*a7c91847Schristos #define mb_isalpha(mbc) ((mbc).wc_valid && iswalpha ((mbc).wc))
224*a7c91847Schristos #define mb_isblank(mbc) ((mbc).wc_valid && iswblank ((mbc).wc))
225*a7c91847Schristos #define mb_iscntrl(mbc) ((mbc).wc_valid && iswcntrl ((mbc).wc))
226*a7c91847Schristos #define mb_isdigit(mbc) ((mbc).wc_valid && iswdigit ((mbc).wc))
227*a7c91847Schristos #define mb_isgraph(mbc) ((mbc).wc_valid && iswgraph ((mbc).wc))
228*a7c91847Schristos #define mb_islower(mbc) ((mbc).wc_valid && iswlower ((mbc).wc))
229*a7c91847Schristos #define mb_isprint(mbc) ((mbc).wc_valid && iswprint ((mbc).wc))
230*a7c91847Schristos #define mb_ispunct(mbc) ((mbc).wc_valid && iswpunct ((mbc).wc))
231*a7c91847Schristos #define mb_isspace(mbc) ((mbc).wc_valid && iswspace ((mbc).wc))
232*a7c91847Schristos #define mb_isupper(mbc) ((mbc).wc_valid && iswupper ((mbc).wc))
233*a7c91847Schristos #define mb_isxdigit(mbc) ((mbc).wc_valid && iswxdigit ((mbc).wc))
234*a7c91847Schristos 
235*a7c91847Schristos /* Extra <wchar.h> function.  */
236*a7c91847Schristos 
237*a7c91847Schristos /* Unprintable characters appear as a small box of width 1.  */
238*a7c91847Schristos #define MB_UNPRINTABLE_WIDTH 1
239*a7c91847Schristos 
240*a7c91847Schristos static inline int
mb_width_aux(wint_t wc)241*a7c91847Schristos mb_width_aux (wint_t wc)
242*a7c91847Schristos {
243*a7c91847Schristos   int w = wcwidth (wc);
244*a7c91847Schristos   /* For unprintable characters, arbitrarily return 0 for control characters
245*a7c91847Schristos      and MB_UNPRINTABLE_WIDTH otherwise.  */
246*a7c91847Schristos   return (w >= 0 ? w : iswcntrl (wc) ? 0 : MB_UNPRINTABLE_WIDTH);
247*a7c91847Schristos }
248*a7c91847Schristos 
249*a7c91847Schristos #define mb_width(mbc) \
250*a7c91847Schristos   ((mbc).wc_valid ? mb_width_aux ((mbc).wc) : MB_UNPRINTABLE_WIDTH)
251*a7c91847Schristos 
252*a7c91847Schristos /* Output.  */
253*a7c91847Schristos #define mb_putc(mbc, stream)  fwrite ((mbc).ptr, 1, (mbc).bytes, (stream))
254*a7c91847Schristos 
255*a7c91847Schristos /* Assignment.  */
256*a7c91847Schristos #define mb_setascii(mbc, sc) \
257*a7c91847Schristos   ((mbc)->ptr = (mbc)->buf, (mbc)->bytes = 1, (mbc)->wc_valid = 1, \
258*a7c91847Schristos    (mbc)->wc = (mbc)->buf[0] = (sc))
259*a7c91847Schristos 
260*a7c91847Schristos /* Copying a character.  */
261*a7c91847Schristos static inline void
mb_copy(mbchar_t * new,const mbchar_t * old)262*a7c91847Schristos mb_copy (mbchar_t *new, const mbchar_t *old)
263*a7c91847Schristos {
264*a7c91847Schristos   if (old->ptr == &old->buf[0])
265*a7c91847Schristos     {
266*a7c91847Schristos       memcpy (&new->buf[0], &old->buf[0], old->bytes);
267*a7c91847Schristos       new->ptr = &new->buf[0];
268*a7c91847Schristos     }
269*a7c91847Schristos   else
270*a7c91847Schristos     new->ptr = old->ptr;
271*a7c91847Schristos   new->bytes = old->bytes;
272*a7c91847Schristos   if ((new->wc_valid = old->wc_valid))
273*a7c91847Schristos     new->wc = old->wc;
274*a7c91847Schristos }
275*a7c91847Schristos 
276*a7c91847Schristos 
277*a7c91847Schristos /* is_basic(c) tests whether the single-byte character c is in the
278*a7c91847Schristos    ISO C "basic character set".
279*a7c91847Schristos    This is a convenience function, and is in this file only to share code
280*a7c91847Schristos    between mbiter_multi.h and mbfile_multi.h.  */
281*a7c91847Schristos #if (' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
282*a7c91847Schristos     && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
283*a7c91847Schristos     && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
284*a7c91847Schristos     && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
285*a7c91847Schristos     && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
286*a7c91847Schristos     && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
287*a7c91847Schristos     && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
288*a7c91847Schristos     && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
289*a7c91847Schristos     && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
290*a7c91847Schristos     && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
291*a7c91847Schristos     && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
292*a7c91847Schristos     && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
293*a7c91847Schristos     && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
294*a7c91847Schristos     && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
295*a7c91847Schristos     && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
296*a7c91847Schristos     && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
297*a7c91847Schristos     && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
298*a7c91847Schristos     && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
299*a7c91847Schristos     && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
300*a7c91847Schristos     && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
301*a7c91847Schristos     && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
302*a7c91847Schristos     && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
303*a7c91847Schristos     && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)
304*a7c91847Schristos /* The character set is ISO-646, not EBCDIC. */
305*a7c91847Schristos # define IS_BASIC_ASCII 1
306*a7c91847Schristos 
307*a7c91847Schristos extern unsigned int is_basic_table[];
308*a7c91847Schristos 
309*a7c91847Schristos static inline bool
is_basic(char c)310*a7c91847Schristos is_basic (char c)
311*a7c91847Schristos {
312*a7c91847Schristos   return (is_basic_table [(unsigned char) c >> 5] >> ((unsigned char) c & 31))
313*a7c91847Schristos 	 & 1;
314*a7c91847Schristos }
315*a7c91847Schristos 
316*a7c91847Schristos #else
317*a7c91847Schristos 
318*a7c91847Schristos static inline bool
is_basic(char c)319*a7c91847Schristos is_basic (char c)
320*a7c91847Schristos {
321*a7c91847Schristos   switch (c)
322*a7c91847Schristos     {
323*a7c91847Schristos     case '\t': case '\v': case '\f':
324*a7c91847Schristos     case ' ': case '!': case '"': case '#': case '%':
325*a7c91847Schristos     case '&': case '\'': case '(': case ')': case '*':
326*a7c91847Schristos     case '+': case ',': case '-': case '.': case '/':
327*a7c91847Schristos     case '0': case '1': case '2': case '3': case '4':
328*a7c91847Schristos     case '5': case '6': case '7': case '8': case '9':
329*a7c91847Schristos     case ':': case ';': case '<': case '=': case '>':
330*a7c91847Schristos     case '?':
331*a7c91847Schristos     case 'A': case 'B': case 'C': case 'D': case 'E':
332*a7c91847Schristos     case 'F': case 'G': case 'H': case 'I': case 'J':
333*a7c91847Schristos     case 'K': case 'L': case 'M': case 'N': case 'O':
334*a7c91847Schristos     case 'P': case 'Q': case 'R': case 'S': case 'T':
335*a7c91847Schristos     case 'U': case 'V': case 'W': case 'X': case 'Y':
336*a7c91847Schristos     case 'Z':
337*a7c91847Schristos     case '[': case '\\': case ']': case '^': case '_':
338*a7c91847Schristos     case 'a': case 'b': case 'c': case 'd': case 'e':
339*a7c91847Schristos     case 'f': case 'g': case 'h': case 'i': case 'j':
340*a7c91847Schristos     case 'k': case 'l': case 'm': case 'n': case 'o':
341*a7c91847Schristos     case 'p': case 'q': case 'r': case 's': case 't':
342*a7c91847Schristos     case 'u': case 'v': case 'w': case 'x': case 'y':
343*a7c91847Schristos     case 'z': case '{': case '|': case '}': case '~':
344*a7c91847Schristos       return 1;
345*a7c91847Schristos     default:
346*a7c91847Schristos       return 0;
347*a7c91847Schristos     }
348*a7c91847Schristos }
349*a7c91847Schristos 
350*a7c91847Schristos #endif
351*a7c91847Schristos 
352*a7c91847Schristos #endif /* _MBCHAR_H */
353