1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.text;
import java.util.*;
public class CharClassStats {
public static class TypeStat {
public final int typecode;
public final String name;
public final List<Integer> codepoints = new ArrayList<Integer>();
TypeStat(int typecode) {
this(typecode, "[???]");
}
TypeStat(int typecode, String name) {
this.typecode = typecode;
this.name = name;
}
void addCodepoint(int codepoint) {
codepoints.add(codepoint);
}
}
private static void init(Map<Integer, TypeStat> map) {
TypeStat stat;
stat = new TypeStat(Character.COMBINING_SPACING_MARK, "COMBINING_SPACING_MARK");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.CONNECTOR_PUNCTUATION, "CONNECTOR_PUNCTUATION");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.CONTROL, "CONTROL");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.CURRENCY_SYMBOL, "CURRENCY_SYMBOL");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.DASH_PUNCTUATION, "DASH_PUNCTUATION");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.DECIMAL_DIGIT_NUMBER, "DECIMAL_DIGIT_NUMBER");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.ENCLOSING_MARK, "ENCLOSING_MARK");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.END_PUNCTUATION, "END_PUNCTUATION");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.FINAL_QUOTE_PUNCTUATION, "FINAL_QUOTE_PUNCTUATION");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.FORMAT, "FORMAT");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.INITIAL_QUOTE_PUNCTUATION, "INITIAL_QUOTE_PUNCTUATION");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.LETTER_NUMBER, "LETTER_NUMBER");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.LINE_SEPARATOR, "LINE_SEPARATOR");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.LOWERCASE_LETTER, "LOWERCASE_LETTER");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.MATH_SYMBOL, "MATH_SYMBOL");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.MODIFIER_LETTER, "MODIFIER_LETTER");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.MODIFIER_SYMBOL, "MODIFIER_SYMBOL");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.NON_SPACING_MARK, "NON_SPACING_MARK");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.OTHER_LETTER, "OTHER_LETTER");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.OTHER_NUMBER, "OTHER_NUMBER");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.OTHER_PUNCTUATION, "OTHER_PUNCTUATION");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.OTHER_SYMBOL, "OTHER_SYMBOL");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.PARAGRAPH_SEPARATOR, "PARAGRAPH_SEPARATOR");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.PRIVATE_USE, "PRIVATE_USE");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.SPACE_SEPARATOR, "SPACE_SEPARATOR");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.START_PUNCTUATION, "START_PUNCTUATION");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.SURROGATE, "SURROGATE");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.TITLECASE_LETTER, "TITLECASE_LETTER");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.UNASSIGNED, "UNASSIGNED");
map.put(stat.typecode, stat);
stat = new TypeStat(Character.UPPERCASE_LETTER, "UPPERCASE_LETTER");
map.put(stat.typecode, stat);
}
public static void main(String[] args) {
Map<Integer, TypeStat> map = new HashMap<Integer, TypeStat>();
init(map);
for (int codepoint = 0; codepoint <= 0x110000; codepoint++) {
int type = java.lang.Character.getType(codepoint);
if (! map.containsKey(type)) {
map.put(type, new TypeStat(type));
}
map.get(type).addCodepoint(codepoint);
}
int[] codes = new int[map.size()];
int numcodes = 0;
for (Integer type : map.keySet()) {
codes[numcodes++] = type;
}
Arrays.sort(codes);
for (int type : codes) {
TypeStat ts = map.get(type);
System.out.println("type "+type+" typecode="+ts.typecode+" name="+ts.name+" contains "+ts.codepoints.size()+" codepoints");
}
}
}
|