Petitcom/CharTBL.pm

filter: Statementstmt 100% 33 / 33 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 2 totaltotal 93.6% 44 / 47 CC 5 SCAR 7.0
CC
5
Cov
97%
dump_char
3.0
load_char
3.0
BEGIN
1.0
CRAP 2.0
« Petitcom/PTC.pm ↑ Summary Petitcom/Resource/PRG.pm »
1 package Data::Petitcom::CharTBL;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 ▶use parent qw { Exporter };
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 our @EXPORT = qw{};
9 4 our @EXPORT_OK = qw{ load_char dump_char };
10  
11 4 ▶use constant GRAPHIC_CHAR => [
Subroutine BEGIN: called CC=1 SCAR=0.0
12 [ 0, " " ], [ 1, "А" ], [ 2, "Б" ], [ 3, "В" ], [ 4, "Г" ], [ 5, "Д" ], [ 6, "Е" ], [ 7, "Ё" ],
13 [ 8, "Ж" ], [ 9, "З" ], [ 10, "И" ], [ 11, "Й" ], [ 12, "К" ], [ 13, "\n" ], [ 14, "М" ], [ 15, "Н" ],
14 [ 16, "♪" ], [ 17, "О" ], [ 18, "н" ], [ 19, "П" ], [ 20, "Р" ], [ 21, "С" ], [ 22, "Т" ], [ 23, "У" ],
15 [ 24, "Ф" ], [ 25, "Х" ], [ 26, "◎" ], [ 27, "Ц" ], [ 28, "→" ], [ 29, "←" ], [ 30, "↑" ], [ 31, "↓" ],
16 [ 128, "◇" ], [ 129, "━" ], [ 130, "┃" ], [ 131, "┏" ], [ 132, "┓" ], [ 133, "┛" ], [ 134, "┗" ], [ 135, "┣" ],
17 [ 136, "┳" ], [ 137, "┫" ], [ 138, "┻" ], [ 139, "╋" ], [ 140, "┠" ], [ 141, "┯" ], [ 142, "┨" ], [ 143, "┷" ],
18 [ 144, "┴" ], [ 145, "┬" ], [ 146, "├" ], [ 147, "┼" ], [ 148, "┤" ], [ 149, "─" ], [ 150, "│" ], [ 151, "┿" ],
19 [ 152, "┌" ], [ 153, "┐" ], [ 154, "└" ], [ 155, "┘" ], [ 156, "┝" ], [ 157, "┰" ], [ 158, "┥" ], [ 159, "┸" ],
20 [ 224, "■" ], [ 225, "●" ], [ 226, "▲" ], [ 227, "▼" ], [ 228, "□" ], [ 229, "○" ], [ 230, "△" ], [ 231, "▽" ],
21 [ 232, "Ч" ], [ 233, "Ш" ], [ 234, "Щ" ], [ 235, "Ъ" ], [ 236, "Ы" ], [ 237, "Ь" ], [ 238, "Э" ], [ 239, "Ю" ],
22 [ 240, "Я" ], [ 241, "а" ], [ 242, "б" ], [ 243, "в" ], [ 244, "г" ], [ 245, "д" ], [ 246, "е" ], [ 247, "ё" ],
23 [ 248, "ж" ], [ 249, "з" ], [ 250, "и" ], [ 251, "й" ], [ 252, "к" ], [ 253, "л" ], [ 254, "м" ], [ 255, "╂" ]
24 4 ];
25  
26 4 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 4 my $enc = Encode::find_encoding('cp932');
28  
29 40 ▶sub load_char {
Subroutine load_char: called CC=3 SCAR=11.0
Pod undocumented
30 40 my $byte = shift;
31 40 my $dec_code = unpack "C", $byte;
32 40 for my $tpl ( @{ GRAPHIC_CHAR() } ) {
33 3676 ▶ return $tpl->[1] if ( $tpl->[0] == $dec_code );
Branch: 1 branch
BranchTrueFalseTotal
if $tpl->[0] == $dec_code 2 3674 3676
34 }
35 38 return $enc->decode($byte);
36 }
37  
38 40 ▶sub dump_char {
Subroutine dump_char: called CC=3 SCAR=11.1
Pod undocumented
39 40 my $char = shift;
40 40 for my $tpl ( @{ GRAPHIC_CHAR() } ) {
41 3840 ▶ return pack( "C*", $tpl->[0] ) if ( $char eq $tpl->[1] );
Branch: 1 branch
BranchTrueFalseTotal
if $char eq $tpl->[1] 0 3840 3840
42 }
43 40 return $enc->encode($char);
44 }
45  
46 4 1;
« Petitcom/PTC.pm ↑ Summary Petitcom/Resource/PRG.pm »