Project

General

Profile

Bug #11807 ยป ct.c

Yuri Pankov, 2020-05-05 12:29 AM

 
1
#include <locale.h>
2
#include <stdio.h>
3
#include <string.h>
4
#include <wchar.h>
5
#include <wctype.h>
6

    
7
const char* CharClasses[] = {
8
	"alnum", "cntrl", "ideogram", "print", "space", "xdigit",
9
	"alpha", "digit", "lower", "punct", "special",
10
	"blank", "graph", "phonogram","rune", "upper"
11
};
12
const int CHAR_CLASS_SIZE = (sizeof(CharClasses) / sizeof(char*));
13
wctype_t CharClassValues[(sizeof(CharClasses) / sizeof(char*))];
14

    
15
void
16
test_char(wchar_t c)
17
{
18
	int i;
19

    
20
	printf("%#06x:", c);
21
	for (i = 0; i < CHAR_CLASS_SIZE; i++) {
22
		if (iswctype(c, CharClassValues[i]))
23
			printf(":%s", CharClasses[i]);
24
	}
25
	printf("\n");
26
}
27

    
28
int
29
main(void)
30
{
31
	int i;
32
	wchar_t c;
33

    
34
	setlocale(LC_ALL, "");
35

    
36
	for (i = 0; i< CHAR_CLASS_SIZE; i++)
37
		CharClassValues[i] = wctype(CharClasses[i]);
38

    
39
	for (c = 0; c < 0xdfff; c++)
40
		test_char(c);
41
	for (c = 0xf900; c < 0xeffff; c++)
42
		test_char(c);
43

    
44
	return (0);
45
}
    (1-1/1)