This source file includes following definitions.
- finish_interval
- add_to_interval
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <config.h>
20
21 #include "uniwidth.h"
22
23 #include <stdio.h>
24
25 #include "macros.h"
26
27
28 static char current_width;
29
30 static ucs4_t current_start;
31 static ucs4_t current_end;
32
33 static void
34 finish_interval (void)
35 {
36 if (current_width != 0)
37 {
38 if (current_start == current_end)
39 printf ("%04X\t\t%c\n", (unsigned) current_start, current_width);
40 else
41 printf ("%04X..%04X\t%c\n", (unsigned) current_start,
42 (unsigned) current_end, current_width);
43 current_width = 0;
44 }
45 }
46
47 static void
48 add_to_interval (ucs4_t uc, char width)
49 {
50 if (current_width == width && uc == current_end + 1)
51 current_end = uc;
52 else
53 {
54 finish_interval ();
55 current_width = width;
56 current_start = current_end = uc;
57 }
58 }
59
60 int
61 main ()
62 {
63 ucs4_t uc;
64
65 for (uc = 0; uc < 0x110000; uc++)
66 {
67 int w1 = uc_width (uc, "UTF-8");
68 int w2 = uc_width (uc, "GBK");
69 char width =
70 (w1 == 0 && w2 == 0 ? '0' :
71 w1 == 1 && w2 == 1 ? '1' :
72 w1 == 1 && w2 == 2 ? 'A' :
73 w1 == 2 && w2 == 2 ? '2' :
74 0);
75 if (width == 0)
76 {
77
78 ASSERT (w1 < 0 && w2 < 0);
79 }
80 else
81 add_to_interval (uc, width);
82 }
83 finish_interval ();
84
85 return 0;
86 }