From: Mischa POSLAWSKY Date: Sat, 8 Apr 2017 01:06:59 +0000 (+0200) Subject: charset: array table for multibyte MacHebrew X-Git-Tag: v1.10~222 X-Git-Url: http://git.shiar.nl/sheet.git/commitdiff_plain/ee2f769329b25592f205cc0d3b9667c49af07a2d charset: array table for multibyte MacHebrew --- diff --git a/charset.plp b/charset.plp index 16a49e9..e2dac1a 100644 --- a/charset.plp +++ b/charset.plp @@ -161,10 +161,18 @@ sub tabinput { or Alert('Table data could not be read', $@ || $!); } else { + if ($row{set} eq 'MacHebrew') { + # array of possibly multiple characters per code point + $row{table} = [ + map { Encode::decode($row{set}, pack 'C*', $_) } $row{offset} .. $endpoint + ]; + } + else { + # ~16x faster than decoding in loop; + # substr strings is twice as fast as splitting to an array + $row{table} = Encode::decode($row{set}, pack 'C*', $row{offset} .. $endpoint); + } $row{len} = $endpoint - $row{offset}; - $row{table} = Encode::decode($row{set}, pack 'C*', $row{offset} .. $endpoint); - # (~16x faster than decoding in loop; - # substr strings is twice as fast as splitting to an array) if ($row{set} eq 'cp437' and !$row{offset}) { substr($row{table}, 237, 1) = pack 'U*', 0x3D5; # phi sign @@ -281,7 +289,8 @@ for my $row (@request) { next; } - my $glyph = substr $row->{table}, $offset, 1; + my $glyph = ref $row->{table} eq 'ARRAY' ? $row->{table}->[$offset] : + substr $row->{table}, $offset, 1; if ($glyph eq $NOCHAR) { print ''; next;