File Coverage

blib/lib/PerlIO/via/Unidecode.pm
Criterion Covered Total %
statement 12 17 70.5
branch 2 4 50.0
condition n/a
subroutine 5 6 83.3
pod 0 2 0.0
total 19 29 65.5


line stmt bran cond sub pod time code
1              
2             require 5.008;
3             package PerlIO::via::Unidecode;
4             # Last-Modified Time-stamp: "2014-07-27 02:49:16 MDT sburke@cpan.org"
5             $VERSION = "1.02";
6 2     2   1729 use strict;
  2         4  
  2         81  
7 2     2   2220 use utf8 ('decode');
  2         22  
  2         12  
8 2     2   1773 use Text::Unidecode ('unidecode');
  2         4411  
  2         550  
9             # A little sanity-checking can't hurt:
10             die "Can't find &Text::Unidecode::unidecode" unless defined &unidecode;
11             die "Can't find &utf8::decode" unless defined &utf8::decode;
12              
13             # Coded based on the example of PerlIO::via::QuotedPrint.
14              
15 1     1 0 16575 sub PUSHED { bless \*PUSHED,$_[0] }
16              
17             sub FILL {
18 4     4 0 4660 my $line = readline( $_[1] );
19 4 100       22 (defined $line) ? unidecode( $line ) : undef;
20             }
21              
22             sub WRITE {
23 0     0     my $x = $_[1];
24 0           utf8::decode($x); # need to promote things back to UTF8
25 0           unidecode($x);
26             # utf8::downgrade($x);
27 0 0         ( print {$_[2]} $x ) ? length($_[1]) : -1;
  0            
28             }
29              
30             1;
31             __END__