X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/8e8998a5c2e51159db372eed7e4e293df83ccc91..0c9d5cd332b3a9124f75926de5094c90b353e238:/charset-encoding.inc.pl diff --git a/charset-encoding.inc.pl b/charset-encoding.inc.pl index d7d1461..71ba2ba 100644 --- a/charset-encoding.inc.pl +++ b/charset-encoding.inc.pl @@ -1,19 +1,80 @@ use 5.014; use warnings; +use utf8; +{ + default => [qw( u+0-27F utf8+realsize iso-8859-1 iso-8859-15 cp1252 cp437 cp850 )], + unicode => [qw( uu+cols=32+realsize u+0-FFF u+1000-18AF u+18B0-1FFF )], + us => [qw( cp437 cp863 gsm0338 AdobeStandardEncoding )], + ebcdic => [qw( cp37 cp500 cp1047 posix-bc cp1026 cp875 )], + iso => [map {"iso-8859-$_"} 1 .. 11, 13 .. 16], + dos => [qw( cp437 cp865 cp861 cp860 cp863 cp850 cp857 cp852 cp775 + cp737 cp869 cp866 cp855 cp862 cp864 )], + aix => [qw( cp1006 )], + win => [qw( cp1252 cp1250 cp1254 cp1257 cp1258 cp1253 cp1251 cp1255 cp1256 cp874 )], + mac => [qw( MacRoman MacRomanian MacRumanian MacCroatian MacCentralEurRoman MacTurkish MacIcelandic MacSami + MacGreek MacCyrillic MacHebrew MacArabic MacFarsi MacThai )], + + # languages + westeur => [qw( iso-8859-1 iso-8859-15 cp1252 iso-8859-14 cp850 hp-roman8 nextstep MacRoman )], + centeur => [qw( iso-8859-2 iso-8859-16 cp1250 cp852 MacRomanian MacCroatian MacCentralEurRoman )], # MacRumanian only for DB + turkish => [qw( iso-8859-9 iso-8859-3 cp1254 cp857 MacTurkish )], + norteur => [qw( baltic nordic )], + baltic => [qw( iso-8859-4 iso-8859-13 cp1257 cp775 )], + nordic => [qw( iso-8859-10 cp865 cp861 MacIcelandic MacSami )], + cyrillic => [qw( koi8-r koi8-u koi8-f iso-8859-5 cp1251 MacCyrillic cp866 cp855 + +400 +2DE0 +A640-A69F +500-52F )], # MacUkrainian is broken + arabic => [qw( iso-8859-6 cp1256 MacArabic cp864 cp1006 MacFarsi + +600 +8A0-8BF+8E0 +750-77F )], + greek => [qw( iso-8859-7 cp1253 MacGreek cp737 cp869 +370 +1F00 )], + hebrew => [qw( iso-8859-8 cp1255 MacHebrew cp862 +590 )], + thai => [qw( iso-8859-11 cp874 MacThai )], + vietnamese => [qw( viscii cp1258 MacVietnamese )], + symbols => [qw( symbol dingbats MacDingbats wingdings wingdings2 wingdings3 webdings )], + + # iso-code shorthand + 1 => 'westeur', + 2 => 'centeur', + 3 => 'turkish', + 4 => 'baltic', + 5 => 'cyrillic', + 6 => 'arabic', + 7 => 'greek', + 8 => 'hebrew', + 9 => 'turkish', + 10 => 'nordic', + 11 => 'thai', + 'ascii' => {inherit => ['' => '00-7F']}, - 'cp437' => {inherit => ['cp850' => 0, 'ascii' => '00-1F+80']}, # ascii range overridden later + 'cp437' => { + inherit => ['cp850' => 0, 'ascii' => '00-1F+80'], # ascii range overridden later + replace => { + 0 => ' ☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼', # visible variants of control characters + 0xED => 'ϕ', # non-greek usage and appearance + }, + }, 'gsm0338' => {inherit => ['ascii' => '00-7F']}, 'dingbats' => {inherit => ['' => '20-7F+A0']}, - 'MacDingbats' => {inherit => ['dingbats' => '80-9F']}, - 'AdobeZdingbat'=> {inherit => ['MacDingbats' => '80-9F']}, # should be identical but maps to private use - 'symbol' => {inherit => ['' => '20-7F+A0']}, - 'AdobeSymbol' => {inherit => ['symbol' => '20-7F+A0', '' => '20-7F+A0']}, # minor differences, irrelevant except for different '€' - 'wingdings' => {inherit => ['' => '20']}, - 'wingdings2' => {inherit => ['' => '20']}, - 'wingdings3' => {inherit => ['' => '20']}, - 'webdings' => {inherit => ['' => '20']}, + 'macdingbats' => {inherit => ['dingbats' => '80-9F']}, + 'adobezdingbat'=> {inherit => ['MacDingbats' => '80-9F']}, # should be identical but maps to private use + 'symbol' => { + inherit => ['' => '20-7F+A0'], + replace => { + 0x60 => '│', # replace radical extender by closest unicode equivalent + 0xBD => '⏐⎯', # arrow extenders + 0xD2 => '®©™', # serif variants + 0xE0 => '◊', # replace lookalike, should match AdobeSymbol + 0xE2 => '®©™', # sans-serif variants + 0xE6 => '⎛⎜⎝⎡⎢⎣⎧⎨⎩⎪', + 0xF0 => '€', + 0xF4 => '⎮⌡⎞⎟⎠⎤⎥⎦⎫⎬⎭', + }, + }, + 'adobesymbol' => {inherit => ['symbol' => '20-7F+A0', '' => '20-7F+A0']}, # minor differences, irrelevant except for different '€' + 'wingdings' => {inherit => ['' => '20'], setup => sub {require Encode::Wingdings}}, + 'wingdings2' => {inherit => ['' => '20'], setup => sub {require Encode::Wingdings2}}, + 'wingdings3' => {inherit => ['' => '20'], setup => sub {require Encode::Wingdings3}}, + 'webdings' => {inherit => ['' => '20'], setup => sub {require Encode::Webdings}}, 'iso-8859-2' => {inherit => ['iso-8859-1' => 'A0']}, 'iso-8859-3' => {inherit => ['iso-8859-1' => 'A0']}, #TODO: also apply to iso-8859-9 @@ -61,18 +122,18 @@ use warnings; 'koi8-u' => {inherit => ['koi8-r' => '90-BF']}, 'koi8-f' => {inherit => ['koi8-u' => '90-BF']}, - 'MacRomanian' => {inherit => ['MacRoman' => 'A0-BF+D0-DF']}, - 'MacRumanian' => {inherit => ['MacRomanian' => 'A0-BF+D0-DF', 'MacRoman' => 'A0-BF+D0-DF']}, - 'MacCroatian' => {inherit => ['MacRoman' => 'A0']}, - 'MacCentralEurRoman' => {inherit => ['MacRoman' => '80']}, - 'MacIcelandic' => {inherit => ['MacRoman' => 'A0-AF+D0-EF']}, - 'MacTurkish' => {inherit => ['MacRoman' => 'D0-DF']}, # F5 is unassigned - 'MacSami' => {inherit => ['MacIcelandic' => '90-BF+D0-DF+F0', 'MacRoman' => '90']}, - 'MacGreek' => {inherit => ['MacRoman' => '80']}, - 'MacCyrillic' => {inherit => ['MacRoman' => '80']}, - 'MacHebrew' => {inherit => ['iso-8859-8' => '80', 'MacRoman' => '80-8F+A0']}, # partial ascii - 'MacArabic' => {inherit => ['iso-8859-6' => '80', 'cp864' => '80', 'MacRoman' => '80']}, #TODO: multiple parents - 'MacFarsi' => {inherit => ['MacArabic' => 'B0-BF', 'MacRoman' => '80']}, + 'macromanian' => {inherit => ['MacRoman' => 'A0-BF+D0-DF']}, + 'macrumanian' => {inherit => ['MacRomanian' => 'A0-BF+D0-DF', 'MacRoman' => 'A0-BF+D0-DF']}, + 'maccroatian' => {inherit => ['MacRoman' => 'A0']}, + 'maccentraleurroman' => {inherit => ['MacRoman' => '80']}, + 'macicelandic' => {inherit => ['MacRoman' => 'A0-AF+D0-EF']}, + 'macturkish' => {inherit => ['MacRoman' => 'D0-DF']}, # F5 is unassigned + 'macsami' => {inherit => ['MacIcelandic' => '90-BF+D0-DF+F0', 'MacRoman' => '90']}, + 'macgreek' => {inherit => ['MacRoman' => '80']}, + 'maccyrillic' => {inherit => ['MacRoman' => '80']}, + 'machebrew' => {inherit => ['iso-8859-8' => '80', 'MacRoman' => '80-8F+A0']}, # partial ascii + 'macarabic' => {inherit => ['iso-8859-6' => '80', 'cp864' => '80', 'MacRoman' => '80']}, #TODO: multiple parents + 'macfarsi' => {inherit => ['MacArabic' => 'B0-BF', 'MacRoman' => '80']}, 'cp37' => {inherit => ['posix-bc' => '00']}, 'posix-bc' => {inherit => ['cp1047' => '40']}, @@ -80,4 +141,55 @@ use warnings; 'cp1047' => {inherit => ['cp37' => '10-2F+50-5F+A0-BF']}, 'cp1026' => {inherit => ['cp37' => '40']}, 'cp875' => {inherit => ['cp37' => '30']}, + + '' => {setup => sub { + my $row = shift; + $row->{offset} = delete $row->{startpoint}; + $row->{set} = 'Unicode characters'; + my $block = $row->{offset} >> 8; + $row->{endpoint} ||= ($block + 1 << 8) - 1; + $block == ($row->{endpoint} >> 8) or undef $block; + + $row->{table} = join '', map { chr } $row->{offset} .. $row->{endpoint}; + utf8::upgrade($row->{table}); # prevent latin1 output + + $row->{endpoint} -= $row->{offset}; + + if (defined $block) { + $row->{set} = sprintf 'Unicode block U+%02Xxx', $block; + $row->{offset} %= 0x100; + } + + return $row; + }}, + u => {setup => sub { + my $row = shift; + $row->{cell} = do 'charset-unicode.inc.pl' + or Alert('Table data could not be read', $@ || $!); + + $row->{endpoint} ||= 0x1FFF; + $row->{set} = 'Unicode ' . ( + $row->{startpoint} < 0x1000 && $row->{endpoint} < 0x1000 ? 'BMP' : + $row->{startpoint} >= 0x1000 && $row->{endpoint} < 0x2000 ? 'SMP' : + 'allocations' + ); + return $row; + }}, + uu => {setup => sub { + my $row = shift; + $row->{cell} = do 'charset-ucplanes.inc.pl' + or Alert('Table data could not be read', $@ || $!); + $row->{endpoint} ||= 0x3FF; + $row->{set} = 'Unicode planes'; + return $row; + }}, + utf8 => {setup => sub { + my $row = shift; + $row->{set} = 'UTF-8'; + $row->{cell} = do 'charset-utf8.inc.pl' + or Alert('Table data could not be read', $@ || $!); + $row->{endpoint} = 0xFF; + return $row; + }}, + 'utf-8' => 'utf8', };