The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Catalyst::Controller::Mobile::JP - decode/encode with Encode::JP::Mobile

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}"
      );
  }

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 にあるように使います。 begin$c->req->params の Encode::decode()、end$c->res->body の Encode::encode() を行ないます。

エンコーディングは UserAgent の値を元に Encode::JP::Mobile から おすすめのものが利用されます(HTTP::MobileAgent::Plugin::Charset)ので、 アプリケーション内部では特に意識せずキャリアをまたいだ絵文字を含む文字情報を Unicode として扱うことができます。

ACCESSOR

encoding

利用されるエンコーディングの Encode::Encoding オブジェクトが 入っています。

  $self->encoding->name;      # x-sjis-docomo
  $self->encoding->mime_name; # Shift_JIS

USE WITH CUSTOM end() METHOD

コントローラーで beginend を実装する場合は、以下のように next::method でこのモジュールのメソッドを呼んでください。

  sub render :ActionClass('RenderView') {
  
  }
  
  sub end :Private {
      my ($self, $c) = @_;
      
      $c->stash->{encoding} = $self->encoding;
      $c->forward('render');
  
      $self->next::method($c);
  }

AUTHOR

Naoki Tomita <tomita@cpan.org>

DEVELOPMENT

http://coderepos.org/share/browser/lang/perl/Catalyst-Controller-Mobile-JP (repository)

#mobilejp on irc.freenode.net (I've joined as "tomi-ru")

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

Encode::JP::Mobile, HTTP::MobileAgent::Plugin::Charset, Catalyst::View::MobileJpFilter