index: release v1.18 with only altgr index linked
[sheet.git] / charset.inc.pl
1 use 5.014;
2 use warnings;
3 use utf8;
4
5 +{
6         %{ Data('./charset-encoding') },
7
8         ''             => {setup => sub {
9                 my $row = shift;
10                 $row->{offset} = delete $row->{startpoint};
11                 $row->{set} = 'Unicode characters';
12                 my $block = $row->{offset} >> 8;
13                 $row->{endpoint} ||= ($block + 1 << 8) - 1;
14                 $block == ($row->{endpoint} >> 8) or undef $block;
15
16                 $row->{table} = join '', map { chr =~ s/\A\p{Unassigned}\z/�/r }
17                         $row->{offset} .. $row->{endpoint};
18                 utf8::upgrade($row->{table});  # prevent latin1 output
19
20                 $row->{endpoint} -= $row->{offset};
21
22                 if (defined $block) {
23                         $row->{set} = sprintf 'Unicode block U+%02Xxx', $block;
24                         $row->{offset} %= 0x100;
25                 }
26
27                 return $row;
28         }},
29         u              => {setup => sub {
30                 my $row = shift;
31                 state $celldata = eval { Data('charset-unicode') }
32                         or Alert('Table data could not be read', ref $@ && $@->[1]);
33                 $row->{cell} = $celldata;
34
35                 $row->{endpoint} ||= 0x1FFF;
36                 $row->{set} = 'Unicode ' . (
37                         $row->{startpoint} <  0x1000 && $row->{endpoint} < 0x1000 ? 'BMP' :
38                         $row->{startpoint} >= 0x1000 && $row->{endpoint} < 0x2000 ? 'SMP' :
39                         'allocations'
40                 );
41                 return $row;
42         }},
43         uu             => {setup => sub {
44                 my $row = shift;
45                 $row->{cell} = eval { Data('charset-ucplanes') }
46                         or Alert('Table data could not be read', ref $@ && $@->[1]);
47                 $row->{endpoint} ||= 0x3FF;
48                 $row->{set} = 'Unicode planes';
49                 return $row;
50         }},
51         utf8           => {setup => sub {
52                 my $row = shift;
53                 $row->{set} = 'UTF-8';
54                 $row->{cell} = eval { Data('charset-utf8') }
55                         or Alert('Table data could not be read', ref $@ && $@->[1]);
56                 return $row;
57         }},
58         'utf-8'        => 'utf8',
59 };