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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
|
BEGIN {
if (ord("A") == 193) {
print "1..0 # Skip: EBCDIC\n";
exit 0;
}
chdir 't' if -d 't';
@INC = '../lib';
@INC = "::lib" if $^O eq 'MacOS'; # module parses @INC itself
}
use strict;
use Unicode::UCD;
use Test::More;
BEGIN { plan tests => 162 };
use Unicode::UCD 'charinfo';
my $charinfo;
$charinfo = charinfo(0x41);
is($charinfo->{code}, '0041', 'LATIN CAPITAL LETTER A');
is($charinfo->{name}, 'LATIN CAPITAL LETTER A');
is($charinfo->{category}, 'Lu');
is($charinfo->{combining}, '0');
is($charinfo->{bidi}, 'L');
is($charinfo->{decomposition}, '');
is($charinfo->{decimal}, '');
is($charinfo->{digit}, '');
is($charinfo->{numeric}, '');
is($charinfo->{mirrored}, 'N');
is($charinfo->{unicode10}, '');
is($charinfo->{comment}, '');
is($charinfo->{upper}, '');
is($charinfo->{lower}, '0061');
is($charinfo->{title}, '');
is($charinfo->{block}, 'Basic Latin');
is($charinfo->{script}, 'Latin');
$charinfo = charinfo(0x100);
is($charinfo->{code}, '0100', 'LATIN CAPITAL LETTER A WITH MACRON');
is($charinfo->{name}, 'LATIN CAPITAL LETTER A WITH MACRON');
is($charinfo->{category}, 'Lu');
is($charinfo->{combining}, '0');
is($charinfo->{bidi}, 'L');
is($charinfo->{decomposition}, '0041 0304');
is($charinfo->{decimal}, '');
is($charinfo->{digit}, '');
is($charinfo->{numeric}, '');
is($charinfo->{mirrored}, 'N');
is($charinfo->{unicode10}, 'LATIN CAPITAL LETTER A MACRON');
is($charinfo->{comment}, '');
is($charinfo->{upper}, '');
is($charinfo->{lower}, '0101');
is($charinfo->{title}, '');
is($charinfo->{block}, 'Latin Extended-A');
is($charinfo->{script}, 'Latin');
# 0x0590 is in the Hebrew block but unused.
$charinfo = charinfo(0x590);
is($charinfo->{code}, undef, '0x0590 - unused Hebrew');
is($charinfo->{name}, undef);
is($charinfo->{category}, undef);
is($charinfo->{combining}, undef);
is($charinfo->{bidi}, undef);
is($charinfo->{decomposition}, undef);
is($charinfo->{decimal}, undef);
is($charinfo->{digit}, undef);
is($charinfo->{numeric}, undef);
is($charinfo->{mirrored}, undef);
is($charinfo->{unicode10}, undef);
is($charinfo->{comment}, undef);
is($charinfo->{upper}, undef);
is($charinfo->{lower}, undef);
is($charinfo->{title}, undef);
is($charinfo->{block}, undef);
is($charinfo->{script}, undef);
# 0x05d0 is in the Hebrew block and used.
$charinfo = charinfo(0x5d0);
is($charinfo->{code}, '05D0', '05D0 - used Hebrew');
is($charinfo->{name}, 'HEBREW LETTER ALEF');
is($charinfo->{category}, 'Lo');
is($charinfo->{combining}, '0');
is($charinfo->{bidi}, 'R');
is($charinfo->{decomposition}, '');
is($charinfo->{decimal}, '');
is($charinfo->{digit}, '');
is($charinfo->{numeric}, '');
is($charinfo->{mirrored}, 'N');
is($charinfo->{unicode10}, '');
is($charinfo->{comment}, '');
is($charinfo->{upper}, '');
is($charinfo->{lower}, '');
is($charinfo->{title}, '');
is($charinfo->{block}, 'Hebrew');
is($charinfo->{script}, 'Hebrew');
# An open syllable in Hangul.
$charinfo = charinfo(0xAC00);
is($charinfo->{code}, 'AC00', 'HANGUL SYLLABLE-AC00');
is($charinfo->{name}, 'HANGUL SYLLABLE-AC00');
is($charinfo->{category}, 'Lo');
is($charinfo->{combining}, '0');
is($charinfo->{bidi}, 'L');
is($charinfo->{decomposition}, undef);
is($charinfo->{decimal}, '');
is($charinfo->{digit}, '');
is($charinfo->{numeric}, '');
is($charinfo->{mirrored}, 'N');
is($charinfo->{unicode10}, '');
is($charinfo->{comment}, '');
is($charinfo->{upper}, '');
is($charinfo->{lower}, '');
is($charinfo->{title}, '');
is($charinfo->{block}, 'Hangul Syllables');
is($charinfo->{script}, 'Hangul');
# A closed syllable in Hangul.
$charinfo = charinfo(0xAE00);
is($charinfo->{code}, 'AE00', 'HANGUL SYLLABLE-AE00');
is($charinfo->{name}, 'HANGUL SYLLABLE-AE00');
is($charinfo->{category}, 'Lo');
is($charinfo->{combining}, '0');
is($charinfo->{bidi}, 'L');
is($charinfo->{decomposition}, undef);
is($charinfo->{decimal}, '');
is($charinfo->{digit}, '');
is($charinfo->{numeric}, '');
is($charinfo->{mirrored}, 'N');
is($charinfo->{unicode10}, '');
is($charinfo->{comment}, '');
is($charinfo->{upper}, '');
is($charinfo->{lower}, '');
is($charinfo->{title}, '');
is($charinfo->{block}, 'Hangul Syllables');
is($charinfo->{script}, 'Hangul');
$charinfo = charinfo(0x1D400);
is($charinfo->{code}, '1D400', 'MATHEMATICAL BOLD CAPITAL A');
is($charinfo->{name}, 'MATHEMATICAL BOLD CAPITAL A');
is($charinfo->{category}, 'Lu');
is($charinfo->{combining}, '0');
is($charinfo->{bidi}, 'L');
is($charinfo->{decomposition}, '<font> 0041');
is($charinfo->{decimal}, '');
is($charinfo->{digit}, '');
is($charinfo->{numeric}, '');
is($charinfo->{mirrored}, 'N');
is($charinfo->{unicode10}, '');
is($charinfo->{comment}, '');
is($charinfo->{upper}, '');
is($charinfo->{lower}, '');
is($charinfo->{title}, '');
is($charinfo->{block}, 'Mathematical Alphanumeric Symbols');
is($charinfo->{script}, undef);
use Unicode::UCD qw(charblock charscript);
# 0x0590 is in the Hebrew block but unused.
is(charblock(0x590), 'Hebrew', '0x0590 - Hebrew unused charblock');
is(charscript(0x590), undef, '0x0590 - Hebrew unused charscript');
$charinfo = charinfo(0xbe);
is($charinfo->{code}, '00BE', 'VULGAR FRACTION THREE QUARTERS');
is($charinfo->{name}, 'VULGAR FRACTION THREE QUARTERS');
is($charinfo->{category}, 'No');
is($charinfo->{combining}, '0');
is($charinfo->{bidi}, 'ON');
is($charinfo->{decomposition}, '<fraction> 0033 2044 0034');
is($charinfo->{decimal}, '');
is($charinfo->{digit}, '');
is($charinfo->{numeric}, '3/4');
is($charinfo->{mirrored}, 'N');
is($charinfo->{unicode10}, 'FRACTION THREE QUARTERS');
is($charinfo->{comment}, '');
is($charinfo->{upper}, '');
is($charinfo->{lower}, '');
is($charinfo->{title}, '');
is($charinfo->{block}, 'Latin-1 Supplement');
is($charinfo->{script}, undef);
use Unicode::UCD qw(charblocks charscripts);
my $charblocks = charblocks();
ok(exists $charblocks->{Thai}, 'Thai charblock exists');
is($charblocks->{Thai}->[0]->[0], hex('0e00'));
ok(!exists $charblocks->{PigLatin}, 'PigLatin charblock does not exist');
my $charscripts = charscripts();
ok(exists $charscripts->{Armenian}, 'Armenian charscript exists');
is($charscripts->{Armenian}->[0]->[0], hex('0531'));
ok(!exists $charscripts->{PigLatin}, 'PigLatin charscript does not exist');
my $charscript;
$charscript = charscript("12ab");
is($charscript, 'Ethiopic', 'Ethiopic charscript');
$charscript = charscript("0x12ab");
is($charscript, 'Ethiopic');
$charscript = charscript("U+12ab");
is($charscript, 'Ethiopic');
my $ranges;
$ranges = charscript('Ogham');
is($ranges->[0]->[0], hex('1681'), 'Ogham charscript');
is($ranges->[0]->[1], hex('169a'));
use Unicode::UCD qw(charinrange);
$ranges = charscript('Cherokee');
ok(!charinrange($ranges, "139f"), 'Cherokee charscript');
ok( charinrange($ranges, "13a0"));
ok( charinrange($ranges, "13f4"));
ok(!charinrange($ranges, "13f5"));
is(Unicode::UCD::UnicodeVersion, '3.2.0', 'UnicodeVersion');
use Unicode::UCD qw(compexcl);
ok(!compexcl(0x0100), 'compexcl');
ok( compexcl(0x0958));
use Unicode::UCD qw(casefold);
my $casefold;
$casefold = casefold(0x41);
ok($casefold->{code} eq '0041' &&
$casefold->{status} eq 'C' &&
$casefold->{mapping} eq '0061', 'casefold 0x41');
$casefold = casefold(0xdf);
ok($casefold->{code} eq '00DF' &&
$casefold->{status} eq 'F' &&
$casefold->{mapping} eq '0073 0073', 'casefold 0xDF');
ok(!casefold(0x20));
use Unicode::UCD qw(casespec);
my $casespec;
ok(!casespec(0x41));
$casespec = casespec(0xdf);
ok($casespec->{code} eq '00DF' &&
$casespec->{lower} eq '00DF' &&
$casespec->{title} eq '0053 0073' &&
$casespec->{upper} eq '0053 0053' &&
$casespec->{condition} eq undef, 'casespec 0xDF');
$casespec = casespec(0x307);
ok($casespec->{az}->{code} eq '0307' &&
$casespec->{az}->{lower} eq '' &&
$casespec->{az}->{title} eq '0307' &&
$casespec->{az}->{upper} eq '0307' &&
$casespec->{az}->{condition} eq 'az After_Soft_Dotted',
'casespec 0x307');
|