| 1 | package Template::Stash::Encode; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Encode; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Template::Config; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use base $Template::Config::STASH; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 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 | 4 | 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<Template::Stash>). | ||||||||||||||||||||||||||||
| 37 | See below constructor parameter of hash reference. | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | =over 2 | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | =item icode | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | Input charactor code. (See L<Encode>) | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | =item ocode | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | Output charactor code. (See L<Encode>) | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | =back | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | =cut | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=18.9
Pod
documented
| |||||||||||||||||||||||||||||
| 54 | 2 | my $class = shift; | |||||||||||||||||||||||||||
| 55 | 2 | my $self = $class->SUPER::new(@_); | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 2 | ▶ | $self->{icode} = 'utf8' unless (exists $self->{icode} && $self->{icode}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $self->{"icode"} and $self->{"icode"}
MC/DC0%0/2
exists $self->{"icode"} and $self->{"icode"}
exists $self->{"icode"}
$self->{"icode"}
Truth table33%1/3
A and B
A= exists $self->{"icode"}B= $self->{"icode"}
| |||||||||||||||||||||||||||||
| 58 | 2 | ▶ | $self->{ocode} = 'utf8' unless (exists $self->{ocode} && $self->{ocode}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $self->{"ocode"} and $self->{"ocode"}
MC/DC0%0/2
exists $self->{"ocode"} and $self->{"ocode"}
exists $self->{"ocode"}
$self->{"ocode"}
Truth table33%1/3
A and B
A= exists $self->{"ocode"}B= $self->{"ocode"}
| |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 2 | return $self; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =head2 get | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | Override method. | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | =cut | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 4 | ▶ | sub get { | ||||||||||||||||||||||||||
|
Subroutine
get: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 70 | 4 | my $self = shift; | |||||||||||||||||||||||||||
| 71 | 4 | my $result = $self->SUPER::get(@_); | |||||||||||||||||||||||||||
| 72 | 4 | ▶ | return $result if (ref $result); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 4 | Encode::from_to($result, $self->{icode}, $self->{ocode}); | |||||||||||||||||||||||||||
| 75 | 4 | return $result; | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | L<Template>, L<Encode> | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | Toru Yamaguchi, C<< <zigorou at cpan.org> >> | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =head1 BUGS | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | Please report any bugs or feature requests to | ||||||||||||||||||||||||||||
| 89 | C<bug-template-stash-encode at rt.cpan.org>, or through the web interface at | ||||||||||||||||||||||||||||
| 90 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Template-Stash-Encode>. | ||||||||||||||||||||||||||||
| 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<http://annocpan.org/dist/Template-Stash-Encode> | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =item * CPAN Ratings | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | L<http://cpanratings.perl.org/d/Template-Stash-Encode> | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | =item * RT: CPAN's request tracker | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Template-Stash-Encode> | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | =item * Search CPAN | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | L<http://search.cpan.org/dist/Template-Stash-Encode> | ||||||||||||||||||||||||||||
| 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 | 4 | 1; # End of Template::Stash::Encode | |||||||||||||||||||||||||||