1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21: #include <error.h>
22: #include <locale.h>
23: #include <stdio.h>
24: #include <stdlib.h>
25: #include <wchar.h>
26: #include <wctype.h>
27:
28: int
29: main (void)
30: {
31: wctype_t wct;
32: wchar_t buf[1000];
33: int result = 1;
34:
35: setlocale (LC_ALL, "");
36: wprintf (L"locale = %s\n", setlocale (LC_CTYPE, NULL));
37:
38: wct = wctype ("jhira");
39: if (wct == 0)
40: error (EXIT_FAILURE, 0, "jhira: no such character class");
41:
42: if (fgetws (buf, sizeof (buf) / sizeof (buf[0]), stdin) != NULL)
43: {
44: int n;
45:
46: wprintf (L"buf[] = \"%ls\"\n", buf);
47:
48: result = 0;
49:
50: for (n = 0; buf[n] != L'\0'; ++n)
51: {
52: wprintf (L"jhira(U%04lx = %lc) = %d\n", (long) buf[n], buf[n],
53: iswctype (buf[n], wct));
54: result |= ((buf[n] < 0xff && iswctype (buf[n], wct))
55: || (buf[n] > 0xff && !iswctype (buf[n], wct)));
56: }
57: }
58:
59: wct = wctype ("jkata");
60: if (wct == 0)
61: error (EXIT_FAILURE, 0, "jkata: no such character class");
62:
63: if (fgetws (buf, sizeof (buf) / sizeof (buf[0]), stdin) != NULL)
64: {
65: int n;
66:
67: wprintf (L"buf[] = \"%ls\"\n", buf);
68:
69: result = 0;
70:
71: for (n = 0; buf[n] != L'\0'; ++n)
72: {
73: wprintf (L"jkata(U%04lx = %lc) = %d\n", (long) buf[n], buf[n],
74: iswctype (buf[n], wct));
75: result |= ((buf[n] < 0xff && iswctype (buf[n], wct))
76: || (buf[n] > 0xff && !iswctype (buf[n], wct)));
77: }
78: }
79:
80: wct = wctype ("jdigit");
81: if (wct == 0)
82: error (EXIT_FAILURE, 0, "jdigit: no such character class");
83:
84: if (fgetws (buf, sizeof (buf) / sizeof (buf[0]), stdin) != NULL)
85: {
86: int n;
87:
88: wprintf (L"buf[] = \"%ls\"\n", buf);
89:
90: result = 0;
91:
92: for (n = 0; buf[n] != L'\0'; ++n)
93: {
94: wprintf (L"jdigit(U%04lx = %lc) = %d\n", (long) buf[n], buf[n],
95: iswctype (buf[n], wct));
96: result |= ((buf[n] < 0xff && iswctype (buf[n], wct))
97: || (buf[n] > 0xff && !iswctype (buf[n], wct)));
98: }
99: }
100:
101: wct = wctype ("jspace");
102: if (wct == 0)
103: error (EXIT_FAILURE, 0, "jspace: no such character class");
104:
105: if (fgetws (buf, sizeof (buf) / sizeof (buf[0]), stdin) != NULL)
106: {
107: int n;
108:
109: wprintf (L"buf[] = \"%ls\"\n", buf);
110:
111: result = 0;
112:
113: for (n = 0; buf[n] != L'\0'; ++n)
114: {
115: wprintf (L"jspace(U%04lx = %lc) = %d\n", (long) buf[n], buf[n],
116: iswctype (buf[n], wct));
117: result |= ((buf[n] < 0xff && iswctype (buf[n], wct))
118: || (buf[n] > 0xff && !iswctype (buf[n], wct)));
119: }
120: }
121:
122: wct = wctype ("jkanji");
123: if (wct == 0)
124: error (EXIT_FAILURE, 0, "jkanji: no such character class");
125:
126: if (fgetws (buf, sizeof (buf) / sizeof (buf[0]), stdin) != NULL)
127: {
128: int n;
129:
130: wprintf (L"buf[] = \"%ls\"\n", buf);
131:
132: result = 0;
133:
134: for (n = 0; buf[n] != L'\0'; ++n)
135: {
136: wprintf (L"jkanji(U%04lx = %lc) = %d\n", (long) buf[n], buf[n],
137: iswctype (buf[n], wct));
138: result |= ((buf[n] < 0xff && iswctype (buf[n], wct))
139: || (buf[n] > 0xff && !iswctype (buf[n], wct)));
140: }
141: }
142:
143: return result;
144: }