blob: 314b73fd8f3cc4f20d74b0ee3489d2f7499ba92e (
plain)
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
|
#!/usr/bin/perl
use warnings;
use strict;
# Convert Unicode mapping tables to C structures
# Input files may be found at http://unicode.org/Public/MAPPINGS
#
# Usage: conv.pl <input_file>
die "Usage: conv.pl <input_file>\n" if (scalar(@ARGV) != 1);
my @table;
open MAP, "<$ARGV[0]" or die "Failed opening $ARGV[0]: $!\n";
while (<MAP>) {
next if (/^#/);
my @parts = split(/\s+/);
# Ignore ASCII part
next if (hex($parts[0]) < 0x80);
# Convert undefined entries to U+FFFF
if ($parts[1] =~ /^#/) {
push(@table, "0xFFFF");
} else {
push(@table, $parts[1]);
}
}
close MAP;
# You'll have to go through and fix up the structure name
print "static uint32_t ${ARGV[0]}[128] = {\n\t";
my $count = 0;
foreach my $item (@table) {
print "$item, ";
$count++;
if ($count % 8 == 0 && $count != 128) {
print "\n\t";
}
}
print "\n};\n\n";
|