gen-combining.pl
text/x-perl-script
Filename: gen-combining.pl
Type: text/x-perl-script
Part: 0
Message:
Update list of combining characters
use strict;
use warnings;
my $range_start = undef;
my $count = 0;
print "\tstatic const struct mbinterval combining[] = {";
foreach my $line (<ARGV>)
{
chomp $line;
my @fields = split ';', $line;
my $codepoint = hex $fields[0];
next if $codepoint > 0xFFFF;
if ($fields[2] eq 'Me' || $fields[2] eq 'Mn')
{
# combining character, save for start of range
if (!defined($range_start))
{
$range_start = $codepoint;
}
}
else
{
# not a combining character, print out previous range if any
if (defined($range_start))
{
if ($count++ % 3 == 0)
{
print "\n\t\t";
}
else
{
print " ";
}
printf "{0x%04X, 0x%04X},", $range_start, $codepoint;
$range_start = undef;
}
}
}
print "\n\t};\n";