Catalyst-Controller-Mobile-JP
view release on metacpan or search on metacpan
lib/Catalyst/Controller/Mobile/JP.pm view on Meta::CPAN
sub end :Private {
my ($self, $c) = @_;
my $body = $c->res->body;
if ($body and
not ref($body) and
$c->res->content_type =~ $decoding_content_type) {
$body = $self->encoding->encode($body, sub {
my $char = shift;
my $out = Encode::JP::Mobile::FB_CHARACTER()->($char);
if ($c->res->content_type =~ /html$|xml$/) {
$out =~ s/([$htmlspecialchars])/$htmlspecialchars{$1}/ego; # for (>ï¼<)
}
$out;
});
$c->res->body($body);
}
}
1;
__END__
=encoding utf-8
=head1 NAME
Catalyst::Controller::Mobile::JP - decode/encode with Encode::JP::Mobile
=head1 SYNOPSIS
package MyApp;
use Catalyst qw/ MobileAgent /;
...
package MyApp::Controller::Root;
use strict;
use base 'Catalyst::Controller::Mobile::JP';
__PACKAGE__->config->{namespace} = '';
sub foo :Local {
my ($self, $c) = @_;
$c->res->body(
$c->req->param('text') . "\x{E72A}"
);
}
=head1 DESCRIPTION
Catalyst::Controller::Mobile::JP works as a base controller
that automatically decode()/encode() with the recommended encoding
lead from values of UserAgent.
You can use unicode in your app that includes cross-carrier pictograms.
ãã®ã¢ã¸ã¥ã¼ã«ã¯ Catalyst::Controller ã§ãSYNOPSIS ã«ããããã«ä½¿ãã¾ãã
C<begin> ã§ C<< $c->req->params >> ã® Encode::decode()ãC<end> ã§
C<< $c->res->body >> ã® Encode::encode() ãè¡ãªãã¾ãã
ã¨ã³ã³ã¼ãã£ã³ã°ã¯ UserAgent ã®å¤ãå
ã« L<Encode::JP::Mobile> ãã
ããããã®ãã®ãå©ç¨ããã¾ãï¼L<HTTP::MobileAgent::Plugin::Charset>ï¼ã®ã§ã
ã¢ããªã±ã¼ã·ã§ã³å
é¨ã§ã¯ç¹ã«æèãããã£ãªã¢ãã¾ããã çµµæåãå«ãæåæ
å ±ã
Unicode ã¨ãã¦æ±ããã¨ãã§ãã¾ãã
=head1 ACCESSOR
=over 4
=item encoding
å©ç¨ãããã¨ã³ã³ã¼ãã£ã³ã°ã® L<Encode::Encoding> ãªãã¸ã§ã¯ãã
å
¥ã£ã¦ãã¾ãã
$self->encoding->name; # x-sjis-docomo
$self->encoding->mime_name; # Shift_JIS
=back
=head1 USE WITH CUSTOM end() METHOD
ã³ã³ããã¼ã©ã¼ã§ C<begin> ã C<end> ãå®è£
ããå ´åã¯ã以ä¸ã®ããã«
C<next::method> ã§ãã®ã¢ã¸ã¥ã¼ã«ã®ã¡ã½ãããå¼ãã§ãã ããã
sub render :ActionClass('RenderView') {
}
sub end :Private {
my ($self, $c) = @_;
$c->stash->{encoding} = $self->encoding;
$c->forward('render');
$self->next::method($c);
}
=head1 AUTHOR
Naoki Tomita E<lt>tomita@cpan.orgE<gt>
=head1 DEVELOPMENT
L<http://coderepos.org/share/browser/lang/perl/Catalyst-Controller-Mobile-JP> (repository)
#mobilejp on irc.freenode.net (I've joined as "tomi-ru")
=head1 LICENSE
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=head1 SEE ALSO
L<Encode::JP::Mobile>, L<HTTP::MobileAgent::Plugin::Charset>,
( run in 0.734 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )