line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Stash::Encode; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
9592
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
150
|
|
4
|
4
|
|
|
4
|
|
24
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
124
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
4133
|
use Encode; |
|
4
|
|
|
|
|
45291
|
|
|
4
|
|
|
|
|
336
|
|
7
|
4
|
|
|
4
|
|
1865
|
use Template::Config; |
|
4
|
|
|
|
|
2888
|
|
|
4
|
|
|
|
|
118
|
|
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
27
|
use base $Template::Config::STASH; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
31
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Template::Stash::Encode - Encode charactor code on stash variables |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 VERSION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Version 0.03 |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use Template::Stash::Encode; |
26
|
|
|
|
|
|
|
use Template; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my Template $tt = Template->new( |
29
|
|
|
|
|
|
|
STASH => Template::Stash::Encode->new(icode => 'utf8', ocode => 'shiftjis') |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 METHODS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 new |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Constructor (See L). |
37
|
|
|
|
|
|
|
See below constructor parameter of hash reference. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=over 2 |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=item icode |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Input charactor code. (See L) |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item ocode |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Output charactor code. (See L) |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=back |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub new { |
54
|
2
|
|
|
2
|
1
|
35
|
my $class = shift; |
55
|
2
|
|
|
|
|
39
|
my $self = $class->SUPER::new(@_); |
56
|
|
|
|
|
|
|
|
57
|
2
|
50
|
33
|
|
|
81
|
$self->{icode} = 'utf8' unless (exists $self->{icode} && $self->{icode}); |
58
|
2
|
50
|
33
|
|
|
31
|
$self->{ocode} = 'utf8' unless (exists $self->{ocode} && $self->{ocode}); |
59
|
|
|
|
|
|
|
|
60
|
2
|
|
|
|
|
29
|
return $self; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 get |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Override method. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub get { |
70
|
4
|
|
|
4
|
1
|
57447
|
my $self = shift; |
71
|
4
|
|
|
|
|
106
|
my $result = $self->SUPER::get(@_); |
72
|
4
|
50
|
|
|
|
41
|
return $result if (ref $result); |
73
|
|
|
|
|
|
|
|
74
|
4
|
|
|
|
|
30
|
Encode::from_to($result, $self->{icode}, $self->{ocode}); |
75
|
4
|
|
|
|
|
27909
|
return $result; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 SEE ALSO |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
L, L |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 AUTHOR |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Toru Yamaguchi, C<< >> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 BUGS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
89
|
|
|
|
|
|
|
C, or through the web interface at |
90
|
|
|
|
|
|
|
L. |
91
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
92
|
|
|
|
|
|
|
your bug as I make changes. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 SUPPORT |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
perldoc Template::Stash::Encode |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
You can also look for information at: |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=over 4 |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
L |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item * CPAN Ratings |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
L |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
L |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * Search CPAN |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
L |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=back |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Copyright 2006 Toru Yamaguchi, all rights reserved. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
127
|
|
|
|
|
|
|
under the same terms as Perl itself. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; # End of Template::Stash::Encode |