/
unicode_list.pl
49 lines (33 loc) · 1.08 KB
/
unicode_list.pl
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
#!/usr/bin/perl -w
##############################################################################
#
# A simple example using Spreadsheet::WriteExcel to display all available
# Unicode characters in a font.
#
# reverse('©'), May 2004, John McNamara, jmcnamara@cpan.org
#
use strict;
use Spreadsheet::WriteExcel;
my $workbook = Spreadsheet::WriteExcel->new('unicode_list.xls');
my $worksheet = $workbook->add_worksheet();
# Set a Unicode font.
my $uni_font = $workbook->add_format(font => 'Arial Unicode MS');
# Ascii font for labels.
my $courier = $workbook->add_format(font => 'Courier New');
my $char = 0;
# Loop through all 32768 UTF-16BE characters.
#
for my $row (0 .. 2 ** 12 -1) {
for my $col (0 .. 31) {
last if $char == 0xffff;
if ($col % 2 == 0){
$worksheet->write_string($row, $col,
sprintf('0x%04X', $char), $courier);
}
else {
$worksheet->write_utf16be_string($row, $col,
pack('n', $char++), $uni_font);
}
}
}
__END__