line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::FillInForm::ForceUTF8; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
42089
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
80
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
67
|
|
5
|
2
|
|
|
2
|
|
21
|
use base qw(HTML::FillInForm); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
13195
|
|
6
|
2
|
|
|
2
|
|
29293
|
use Encode; |
|
2
|
|
|
|
|
32398
|
|
|
2
|
|
|
|
|
727
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub fill { |
11
|
2
|
|
|
2
|
1
|
86052
|
my ( $self, %option ) = @_; |
12
|
2
|
50
|
33
|
|
|
31
|
if ( exists $option{file} ) { |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
13
|
0
|
0
|
|
|
|
0
|
if ( ref $option{file} ) { |
14
|
0
|
|
|
|
|
0
|
binmode $option{file}, ":utf8"; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
else { |
17
|
0
|
|
|
|
|
0
|
open my $fh, ":utf8", $option{file}; |
18
|
0
|
|
|
|
|
0
|
$option{file} = $fh; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
elsif ( exists $option{scalarref} && !Encode::is_utf8($option{scalarref}) ) { |
22
|
2
|
|
|
|
|
3
|
my $val = ${$option{scalarref}}; |
|
2
|
|
|
|
|
5
|
|
23
|
2
|
|
|
|
|
9
|
Encode::_utf8_on( $val ); |
24
|
2
|
|
|
|
|
6
|
$option{scalarref} = \$val; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
elsif ( exists $option{arrayref} ) { |
27
|
0
|
|
|
|
|
0
|
for ( @{ $option{arrayref} } ) { |
|
0
|
|
|
|
|
0
|
|
28
|
0
|
0
|
|
|
|
0
|
Encode::_utf8_on($_) unless Encode::is_utf8($_); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
2
|
|
|
|
|
23
|
$self->SUPER::fill(%option); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _get_param { |
35
|
2
|
|
|
2
|
|
446
|
my $self = shift; |
36
|
2
|
|
|
|
|
14
|
my $ret = $self->SUPER::_get_param(@_); |
37
|
2
|
50
|
|
|
|
37
|
for ( ref($ret) ? @$ret : $ret ) { |
38
|
2
|
100
|
|
|
|
14
|
Encode::_utf8_on($_) unless Encode::is_utf8($_); |
39
|
|
|
|
|
|
|
} |
40
|
2
|
|
|
|
|
9
|
return $ret; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
__END__ |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=encoding utf-8 |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 NAME |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
HTML::FillInForm::ForceUTF8 - FillInForm with utf8 encoding |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 SYNOPSIS |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
use HTML::FillInForm::ForceUTF8; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my $fif = HTML::FillInForm::ForceUTF8->new; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $fdat; |
59
|
|
|
|
|
|
|
$fdat->{foo} = "\x{306a}\x{304c}\x{306e}"; #Unicode flagged |
60
|
|
|
|
|
|
|
$fdat->{bar} = "\xe3\x81\xaa\xe3\x81\x8c\xe3\x81\xae"; # UTF8 bytes |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my $output = $fif->fill( |
63
|
|
|
|
|
|
|
scalarref => \$html, |
64
|
|
|
|
|
|
|
fdat => $fdat |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 DESCRIPTION |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
HTML::FillInForm::ForceUTF8 is a subclass of HTML::FillInForm that forces utf8 flag on html and parameters. This allows you to prevent filling garbled result. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 SEE ALSO |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
L<HTML::FillInForm> |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 LICENSE |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Copyright (C) Masahiro Nagano. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
80
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 AUTHOR |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Masahiro Nagano E<lt>kazeburo@gmail.comE<gt> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|