| 1 | package HTML::FillInForm::ForceUTF8; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 2 | ▶ | use base qw(HTML::FillInForm); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 2 | ▶ | use Encode; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 2 | our $VERSION = '0.03'; | |||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 2 | ▶ | sub fill { | ||||||||||||||||||
|
Subroutine
fill: called CC=8 SCAR=31.8
Pod
documented
| |||||||||||||||||||||
| 11 | 2 | my ( $self, %option ) = @_; | |||||||||||||||||||
| 12 | 2 | ▶ | if ( exists $option{file} ) { | ||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||
| 13 | 0 | ▶ | if ( ref $option{file} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 14 | 0 | binmode $option{file}, ":utf8"; | |||||||||||||||||||
| 15 | } | ||||||||||||||||||||
| 16 | else { | ||||||||||||||||||||
| 17 | 0 | open my $fh, ":utf8", $option{file}; | |||||||||||||||||||
| 18 | 0 | $option{file} = $fh; | |||||||||||||||||||
| 19 | } | ||||||||||||||||||||
| 20 | } | ||||||||||||||||||||
| 21 | ▶ | elsif ( exists $option{scalarref} && !Encode::is_utf8($option{scalarref}) ) { | |||||||||||||||||||
|
Condition33%1/3
exists $option{"scalarref"} and not &Encode::is_utf8($option{"scalarref"})
MC/DC0%0/2
exists $option{"scalarref"} and not &Encode::is_utf8($option{"scalarref"})
exists $option{"scalarref"}
not &Encode::is_utf8($option{"scalarref"})
Truth table33%1/3
A and not(B)
A= exists $option{"scalarref"}B= not &Encode::is_utf8($option{"scalarref"})
| |||||||||||||||||||||
| 22 | 2 | my $val = ${$option{scalarref}}; | |||||||||||||||||||
| 23 | 2 | Encode::_utf8_on( $val ); | |||||||||||||||||||
| 24 | 2 | $option{scalarref} = \$val; | |||||||||||||||||||
| 25 | } | ||||||||||||||||||||
| 26 | elsif ( exists $option{arrayref} ) { | ||||||||||||||||||||
| 27 | 0 | for ( @{ $option{arrayref} } ) { | |||||||||||||||||||
| 28 | 0 | ▶ | Encode::_utf8_on($_) unless Encode::is_utf8($_); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 29 | } | ||||||||||||||||||||
| 30 | } | ||||||||||||||||||||
| 31 | 2 | $self->SUPER::fill(%option); | |||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 2 | ▶ | sub _get_param { | ||||||||||||||||||
|
Subroutine
_get_param: called CC=4 SCAR=13.9
| |||||||||||||||||||||
| 35 | 2 | my $self = shift; | |||||||||||||||||||
| 36 | 2 | my $ret = $self->SUPER::_get_param(@_); | |||||||||||||||||||
| 37 | 2 | ▶ | for ( ref($ret) ? @$ret : $ret ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 38 | 2 | ▶ | Encode::_utf8_on($_) unless Encode::is_utf8($_); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 39 | } | ||||||||||||||||||||
| 40 | 2 | return $ret; | |||||||||||||||||||
| 41 | } | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 2 | 1; | |||||||||||||||||||
| 44 | __END__ | ||||||||||||||||||||