File Coverage

blib/lib/Telugu/AsciiMap.pm
Criterion Covered Total %
statement 22 23 95.6
branch 4 8 50.0
condition n/a
subroutine 5 5 100.0
pod n/a
total 31 36 86.1


line stmt bran cond sub pod time code
1             package Telugu::AsciiMap;
2              
3 1     1   55140 use Mouse;
  1         22377  
  1         3  
4 1     1   289 use utf8;
  1         2  
  1         6  
5 1     1   443 use Kavorka -all;
  1         11425  
  1         6  
6              
7             our $VERSION = '0.08';
8              
9              
10             has 'TeMap' => (
11             is => 'ro',
12             isa => 'HashRef',
13             default => sub {
14             return {'à°…' => ',', 'à°†' => '-', 'à°‡' => '.', 'à°ˆ' => '/', 'à°‰' => '0', 'à°Š' => '1', 'à°‹' => '2', 'à± ' => '3', 'à°Œ' => '4', 'ౡ' => '5', 'à°Ž' => '6', 'ఏ' => '7', 'ఐ' => '8', 'à°’' => '9', 'à°“' => ':', 'à°”' => ';', 'à°‚' => '<', 'à°ƒ' => '=', 'ఁ' => '>', '్' => '?', 'à°•' => '@', 'à°–' => 'A', 'à°—' => 'B', 'à°˜' => 'C', 'à°™' => 'D', 'à°š' => 'E', 'à°›' => 'F', 'à°œ' => 'G', 'ఝ' => 'H', 'à°ž' => 'I', 'à°Ÿ' => 'J', 'à° ' => 'K', 'à°¡' => 'L', 'à°¢' => 'M', 'à°£' => 'N', 'à°¤' => 'O', 'à°¥' => 'P', 'à°¦' => 'Q', 'à°§' => 'R', 'à°¨' => 'S', 'à°ª' => 'T', 'à°«' => 'U', 'à°¬' => 'V', 'à°­' => 'W', 'à°®' => 'X', 'à°¯' => 'Y', 'à°°' => 'Z', 'à°²' => '[', 'à°µ' => 'à°µ', 'à°¶' => ']', 'à°·' => '^', 'à°¸' => '_', 'à°¹' => '`', 'à°³' => 'a', 'à°¾' => 'b', 'à°¿' => 'c', 'à±€' => 'd', 'ు' => 'e', 'ూ' => 'f', 'ృ' => 'g', 'ౄ' => 'h', 'à±¢' => 'i', 'à±£' => 'j', 'ె' => 'k', 'ే' => 'l', 'ై' => 'm', 'ొ' => 'n', 'ో' => 'o', 'ౌ' => 'p', '౦' => 'q', '౧' => 'r', '౨' => 's', '౩' => 't', '౪' => 'u', '౫' => 'v', '౬' => 'w', 'à±­' => 'x', 'à±®' => 'y', '౯' => 'z', 'à°“à°‚' => '{'
15             , ',' => 'à°…', '-' => 'à°†', '.' => 'à°‡', '/' => 'à°ˆ', '0' => 'à°‰', '1' => 'à°Š', '2' => 'à°‹', '3' => 'à± ', '4' => 'à°Œ', '5' => 'ౡ', '6' => 'à°Ž', '7' => 'ఏ', '8' => 'ఐ', '9' => 'à°’', ':' => 'à°“', ';' => 'à°”', '<' => 'à°‚', '=' => 'à°ƒ', '>' => 'ఁ', '?' => '్', '@' => 'à°•', 'A' => 'à°–', 'B' => 'à°—', 'C' => 'à°˜', 'D' => 'à°™', 'E' => 'à°š', 'F' => 'à°›', 'G' => 'à°œ', 'H' => 'ఝ', 'I' => 'à°ž', 'J' => 'à°Ÿ', 'K' => 'à° ', 'L' => 'à°¡', 'M' => 'à°¢', 'N' => 'à°£', 'O' => 'à°¤', 'P' => 'à°¥', 'Q' => 'à°¦', 'R' => 'à°§', 'S' => 'à°¨', 'T' => 'à°ª', 'U' => 'à°«', 'V' => 'à°¬', 'W' => 'à°­', 'X' => 'à°®', 'Y' => 'à°¯', 'Z' => 'à°°', '[' => 'à°²', 'à°µ' => 'à°µ', ']' => 'à°¶', '^' => 'à°·', '_' => 'à°¸', '`' => 'à°¹', 'a' => 'à°³', 'b' => 'à°¾', 'c' => 'à°¿', 'd' => 'à±€', 'e' => 'ు', 'f' => 'ూ', 'g' => 'ృ', 'h' => 'ౄ', 'i' => 'à±¢', 'j' => 'à±£', 'k' => 'ె', 'l' => 'ే', 'm' => 'ై', 'n' => 'ొ', 'o' => 'ో', 'p' => 'ౌ', 'q' => '౦', 'r' => '౧', 's' => '౨', 't' => '౩', 'u' => '౪', 'v' => '౫', 'w' => '౬', 'x' => 'à±­', 'y' => 'à±®', 'z' => '౯', '{' => 'à°“à°‚'};
16             }
17             );
18              
19 1 50   1   262182 method asciimap($string) {
  1 50   2   2  
  1 50       293  
  2         12  
  2         5  
  2         5  
  2         3  
20 2         6 my @stringsplit = split('', $string);
21 2         4 my @out;
22 2         6 for my $c (0..$#stringsplit) {
23 18 50       30 if( defined($self->TeMap->{$stringsplit[$c]}) ) {
24 18         35 push @out, $self->TeMap->{$stringsplit[$c]};
25             }
26             else {
27 0         0 push @out, $stringsplit[$c];
28             }
29             }
30 2         9 return join("", @out);
31             }
32              
33             1;
34             __END__
35             =encoding utf-8
36              
37             =head1 NAME
38              
39             Telugu::AsciiMap - Map Telugu chars to ascii chars to save space
40              
41             =head1 SYNOPSIS
42              
43             use Telugu::AsciiMap;
44             use utf8;
45             binmode STDOUT, ":encoding(UTF-8)";
46              
47             my $map = Telugu::AsciiMap->new();
48             my $asciistring = $map->asciimap('రాజ్కుమార్రెడ్డి'); # use asciimap method to convert telugu text to ascii
49             my $telugustring = $map->asciimap($asciistring); # use the same method to convet back ascii text to telugu
50             print $asciistring, "\n", $telugustring, "\n";
51              
52              
53             =head1 DESCRIPTION
54              
55             Each Telugu char uses four times the space required for an ascii char.
56             This module provides a functions to convert Telugu text to ascii text and to convert back that ascii text to Telugu.
57              
58              
59             =head1 AUTHOR
60              
61             Rajkumar Reddy, mesg.raj@outlook.com
62              
63             =head1 COPYRIGHT AND LICENSE
64              
65             Copyright (C) 2019 by Rajkumar Reddy
66              
67             This library is free software; you can redistribute it and/or modify
68             it under the same terms as Perl itself, either Perl version 5.26.1 or,
69             at your option, any later version of Perl 5 you may have available.
70              
71             =cut