font: file ids and os grouping
[sheet.git] / tools / convert-unicode.pl
index 348878cf62da3d0f9d37d165d456bf2cf8fa86f0..19fde5dda9a3109eeb003b6d6079991940979ab2 100755 (executable)
@@ -30,6 +30,15 @@ eval {
        1;
 } or warn "Failed reading unicode tables: $@";
 
+eval {
+       require HTML::Entities;
+       while (my ($char, $entity) = each %HTML::Entities::char2entity) {
+               $entity =~ /[a-zA-Z]/ or next;  # only actual aliases
+               $info{$char}->{html} = substr($entity, 1, -1);
+       }
+       1;
+} or warn "Failed importing html entities: $@";
+
 my %diinc = (
        'digraphs.inc.pl' => 'u-di',
 );
@@ -53,7 +62,7 @@ for my $chr (keys %info) {
                        || { block => '?', category => 'Xn', name => '', script => '' }
        } or next;
 
-       $info->{$_} = $info{$chr}->{$_} for qw(di class string);
+       $info->{$_} = $info{$chr}->{$_} for qw(di html class string);
 
        # categorise by unicode types and writing script
        $info->{class}->{$_}++ for $info->{category};
@@ -90,7 +99,7 @@ say '+{';
 for my $cp (sort keys %info) {
        $info{$cp}->{classstr} = join(' ', sort keys %{ $info{$cp}->{class} });
        # convert info hashes into arrays of strings to output in display order
-       my $row = [ map { $info{$cp}->{$_} } qw/classstr name di string/ ];
+       my $row = [ map { $info{$cp}->{$_} } qw/classstr name di html string/ ];
        # strip off trailing missing values (especially string may be unknown)
        defined $row->[-1] ? last : pop @$row for 1 .. @$row;
        # final line (assume safe within single quotes)