Index: lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/02_fallback.t
===================================================================
--- lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/02_fallback.t (revision 15140)
+++ lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/02_fallback.t (revision 15140)
@@ -0,0 +1,40 @@
+use strict;
+use warnings;
+use Test::Base;
+use FindBin;
+use lib "$FindBin::Bin/lib";
+use HTTP::Request::Common;
+
+plan tests => 1 + 1 * blocks;
+
+use_ok('Catalyst::Test', 'TestApp');
+
+filters {
+    expected => [qw( eval )],
+};
+
+run {
+    my $block = shift;
+    my $res = request(
+        POST '/fallback_test',
+        User_Agent => $block->user_agent,
+    );
+    is(
+        $res->content,
+        $block->expected,
+        $block->name
+    );
+}
+
+__DATA__
+=== xhtml_compliant docomo
+--- user_agent: DoCoMo/2.0 SH902i(c100;TB;W24H12)
+--- expected: "\xEE\x9B\x91[EZ][WC]"
+
+=== au
+--- user_agent: KDDI-SA31 UP.Browser/6.2.0.6.3.129 (GUI) MMP/2.0
+--- expected: "\x81\x6d\x82\x89\x83\x82\x81\x5b\x83\x68\x81\x6e\xF7\x94[WC]"
+
+=== 3gc softbank
+--- user_agent: SoftBank/1.0/821T/TJ001/SN*************** Browser/NetFront/3.3
+--- expected: "［ｉモード］[EZ]\xEE\x8C\x89"
Index: lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/98_perlcritic.t
===================================================================
--- lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/98_perlcritic.t (revision 14885)
+++ lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/98_perlcritic.t (revision 14885)
@@ -0,0 +1,5 @@
+use strict;
+use Test::More;
+eval q{ use Test::Perl::Critic };
+plan skip_all => "Test::Perl::Critic is not installed." if $@;
+all_critic_ok("lib");
Index: lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/97_podspell.t
===================================================================
--- lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/97_podspell.t (revision 14885)
+++ lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/97_podspell.t (revision 14885)
@@ -0,0 +1,10 @@
+use Test::More;
+eval q{ use Test::Spelling };
+plan skip_all => "Test::Spelling is not installed." if $@;
+add_stopwords(map { split /[\s\:\-]/ } <DATA>);
+$ENV{LANG} = 'C';
+all_pod_files_spelling_ok('lib');
+__DATA__
+Naoki Tomita
+tomi-ru
+Catalyst::Controller::Mobile::JP
Index: lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/99_pod.t
===================================================================
--- lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/99_pod.t (revision 14885)
+++ lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/99_pod.t (revision 14885)
@@ -0,0 +1,4 @@
+use Test::More;
+eval "use Test::Pod 1.00";
+plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
+all_pod_files_ok();
Index: lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/96_dependencies.t
===================================================================
--- lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/96_dependencies.t (revision 16854)
+++ lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/96_dependencies.t (revision 16854)
@@ -0,0 +1,5 @@
+use Test::Dependencies
+    exclude => [qw( Test::Dependencies Catalyst::Controller::Mobile::JP )],
+    style => 'light';
+
+ok_dependencies();
Index: lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/lib/TestApp/Controller/Root.pm
===================================================================
--- lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/lib/TestApp/Controller/Root.pm (revision 15140)
+++ lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/lib/TestApp/Controller/Root.pm (revision 15140)
@@ -0,0 +1,31 @@
+package TestApp::Controller::Root;
+use strict;
+use base 'Catalyst::Controller::Mobile::JP';
+
+__PACKAGE__->config->{namespace} = '';
+
+use Encode;
+
+sub param_test :Local {
+    my ($self, $c) = @_;
+    $c->res->body(
+        $self->encoding->name . '/' .
+        Encode::encode('ascii', $c->req->param('text'), Encode::FB_XMLCREF) . '/' .
+        $c->req->param('text')
+    );
+}
+
+sub fallback_test :Local {
+    my ($self, $c) = @_;
+    $c->res->content_type('text/plain');
+    $c->res->body("\x{E6D1}\x{F094}\x{E309}");
+    # [DoCoMoにしかないiモードマーク][auにしかないEZマーク][Softbankにしかないトイレ]
+}
+
+sub htmlspecialchars_test :Local {
+    my ($self, $c) = @_;
+    $c->res->content_type( $c->req->param('content_type') );
+    $c->res->body("\x{ECA2}"); # DoCoMoにないauの顔 (>３<)
+}
+
+1;
Index: lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/lib/TestApp.pm
===================================================================
--- lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/lib/TestApp.pm (revision 15140)
+++ lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/lib/TestApp.pm (revision 15140)
@@ -0,0 +1,8 @@
+package TestApp;
+use strict;
+
+use Catalyst qw/ MobileAgent /;
+
+__PACKAGE__->setup;
+
+1;
Index: lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/03_fallback-htmlspecialchars.t
===================================================================
--- lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/03_fallback-htmlspecialchars.t (revision 15140)
+++ lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/03_fallback-htmlspecialchars.t (revision 15140)
@@ -0,0 +1,35 @@
+use strict;
+use warnings;
+use Test::Base;
+use FindBin;
+use lib "$FindBin::Bin/lib";
+use HTTP::Request::Common;
+
+plan tests => 1 + 1 * blocks;
+
+use_ok('Catalyst::Test', 'TestApp');
+
+run {
+    my $block = shift;
+    my $res = request(
+        POST '/htmlspecialchars_test',
+        User_Agent => $block->user_agent,
+        Content    => [ content_type => $block->content_type ],
+    );
+    is(
+        $res->content,
+        $block->expected,
+        $block->name
+    );
+}
+
+__DATA__
+=== text/plain
+--- user_agent: DoCoMo/2.0 SH902i(c100;TB;W24H12)
+--- content_type: text/plain
+--- expected: (>３<)
+
+=== text/html
+--- user_agent: DoCoMo/2.0 SH902i(c100;TB;W24H12)
+--- content_type: text/html
+--- expected: (&gt;３&lt;)
Index: lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/01_encoding.t
===================================================================
--- lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/01_encoding.t (revision 15140)
+++ lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/01_encoding.t (revision 15140)
@@ -0,0 +1,71 @@
+use strict;
+use warnings;
+use Test::Base;
+use FindBin;
+use lib "$FindBin::Bin/lib";
+use HTTP::Request::Common;
+
+plan tests => 1 + 1 * blocks;
+
+use_ok('Catalyst::Test', 'TestApp');
+
+filters {
+    input => [qw( eval )],
+};
+
+run {
+    my $block = shift;
+    my $res = request(
+        POST '/param_test',
+        User_Agent => $block->user_agent,
+        Content    => [ text => $block->input ],
+    );
+    is(
+        $res->content,
+        join('/', $block->encoding, $block->internal, $block->input),
+        $block->name . ' - ' . $block->comment
+    );
+}
+
+__DATA__
+=== xhtml_compliant docomo
+--- user_agent: DoCoMo/2.0 SH902i(c100;TB;W24H12)
+--- input: "\xE3\x81\x82\xEE\x98\xBE"
+--- comment: [あ][DoCoMoの太陽](utf8)
+--- encoding: x-utf8-docomo
+--- internal: &#x3042;&#xe63e;
+
+=== non xhtml_compliant docomo
+--- user_agent: DoCoMo/1.0/F505i/c20/TB/W20H10
+--- input: "\x82\xA0\xF8\x9F"
+--- comment: [あ][DoCoMoの太陽](sjis)
+--- encoding: x-sjis-docomo
+--- internal: &#x3042;&#xe63e;
+
+=== au
+--- user_agent: KDDI-SA31 UP.Browser/6.2.0.6.3.129 (GUI) MMP/2.0
+--- input: "\x82\xA0\xF6\x60"
+--- comment: [あ][auの太陽](sjis)
+--- encoding: x-sjis-kddi-auto
+--- internal: &#x3042;&#xef60;
+
+=== 3gc softbank
+--- user_agent: SoftBank/1.0/821T/TJ001/SN*************** Browser/NetFront/3.3
+--- input: "\xE3\x81\x82\xEE\x81\x8A"
+--- comment: [あ][softbankの太陽](utf8)
+--- encoding: x-utf8-softbank
+--- internal: &#x3042;&#xe04a;
+
+=== non 3gc softbank
+--- user_agent: J-PHONE/2.0/J-T04
+--- input: "\x82\xA0\x1B\x24\x47\x6A\x0F"
+--- comment: [あ][softbankの太陽ウェブコード](sjis)
+--- encoding: x-sjis-softbank
+--- internal: &#x3042;&#xe04a;
+
+=== non mobile
+--- user_agent: Mozilla/5.0
+--- input: "\xE3\x81\x82"
+--- comment: [あ](utf8)
+--- encoding: utf-8-strict
+--- internal: &#x3042;
Index: lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/00_compile.t
===================================================================
--- lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/00_compile.t (revision 14885)
+++ lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/t/00_compile.t (revision 14885)
@@ -0,0 +1,4 @@
+use strict;
+use Test::More tests => 1;
+
+BEGIN { use_ok 'Catalyst::Controller::Mobile::JP' }
Index: lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/lib/Catalyst/Controller/Mobile/JP.pm
===================================================================
--- lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/lib/Catalyst/Controller/Mobile/JP.pm (revision 16855)
+++ lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/lib/Catalyst/Controller/Mobile/JP.pm (revision 16855)
@@ -0,0 +1,169 @@
+package Catalyst::Controller::Mobile::JP;
+use strict;
+use warnings;
+our $VERSION = '0.02';
+
+use base qw( Catalyst::Controller Class::Accessor::Fast );
+__PACKAGE__->mk_accessors(qw( encoding ));
+
+use Encode;
+use Encode::JP::Mobile ':props';
+use Encode::JP::Mobile::Character;
+use HTTP::MobileAgent::Plugin::Charset;
+
+sub begin :Private {
+    my ($self, $c) = @_;
+    
+    $self->encoding(do {
+        my $encoding = $c->req->mobile_agent->encoding;
+        ref($encoding) && $encoding->isa('Encode::Encoding')
+            ? $encoding
+            : Encode::find_encoding($encoding);
+    });
+    
+    for my $value (values %{ $c->req->{parameters} }) {
+        next if ref $value && ref $value ne 'ARRAY';
+         
+        for my $v (ref($value) ? @$value : $value) {
+            next if Encode::is_utf8($v);
+            $v = $self->encoding->decode($v);
+        }
+    }
+    
+    $c->res->content_type(do {
+        if ($c->req->mobile_agent->is_docomo) {
+            'application/xhtml+xml';
+        } else {
+            'text/html; charset=' . $self->encoding->mime_name;
+        }
+    });
+}
+
+my %htmlspecialchars = ( '&' => '&amp;', '<' => '&lt;', '>' => '&gt;', '"' => '&quot;' );
+my $htmlspecialchars = join '', keys %htmlspecialchars;
+
+our $decoding_content_type = qr{^text|xml$|javascript$};
+
+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>,
+L<Catalyst::View::MobileJpFilter>
+
+=cut
Index: lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/Makefile.PL
===================================================================
--- lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/Makefile.PL (revision 16854)
+++ lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/Makefile.PL (revision 16854)
@@ -0,0 +1,18 @@
+use inc::Module::Install;
+
+name 'Catalyst-Controller-Mobile-JP';
+all_from 'lib/Catalyst/Controller/Mobile/JP.pm';
+
+requires 'Catalyst::Runtime'  => '5.70';
+requires 'Class::Accessor::Fast';
+requires 'Encode::JP::Mobile' => '0.25';
+requires 'Catalyst::Plugin::MobileAgent';
+requires 'HTTP::MobileAgent::Plugin::Charset';
+
+build_requires 'Test::More';
+build_requires 'HTTP::Request::Common';
+
+use_test_base;
+auto_include;
+
+WriteAll;
Index: lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/Changes
===================================================================
--- lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/Changes (revision 16855)
+++ lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/Changes (revision 16855)
@@ -0,0 +1,7 @@
+Revision history for Perl extension Catalyst::Controller::Mobile::JP
+
+0.02  Wed Jul 30 15:00:56 JST 2008
+        - fixed dependencies
+
+0.01  Tue Jul  8 20:27:04 JST 2008
+        - first release
Index: lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/MANIFEST.SKIP
===================================================================
--- lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/MANIFEST.SKIP (revision 14885)
+++ lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/MANIFEST.SKIP (revision 14885)
@@ -0,0 +1,15 @@
+\bRCS\b
+\bCVS\b
+^MANIFEST\.
+^Makefile$
+~$
+\.old$
+^blib/
+^pm_to_blib
+^MakeMaker-\d
+\.gz$
+\.cvsignore
+\.svn/
+\.git/
+\.shipit
+^t/9\d_.*\.t
Index: lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/README
===================================================================
--- lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/README (revision 14885)
+++ lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/README (revision 14885)
@@ -0,0 +1,27 @@
+This is Perl module Catalyst::Controller::Mobile::JP.
+
+INSTALLATION
+
+Catalyst::Controller::Mobile::JP installation is straightforward. If your CPAN shell is set up,
+you should just be able to do
+
+    % cpan Catalyst::Controller::Mobile::JP
+
+Download it, unpack it, then build it as per the usual:
+
+    % perl Makefile.PL
+    % make && make test
+
+Then install it:
+
+    % make install
+
+DOCUMENTATION
+
+Catalyst::Controller::Mobile::JP documentation is available as in POD. So you can do:
+
+    % perldoc Catalyst::Controller::Mobile::JP
+
+to read the documentation online with your favorite pager.
+
+Naoki Tomita
Index: lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/.shipit
===================================================================
--- lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/.shipit (revision 14885)
+++ lang/perl/Catalyst-Controller-Mobile-JP/tags/0.02/.shipit (revision 14885)
@@ -0,0 +1,1 @@
+steps = FindVersion, ChangeVersion, CheckChangeLog, DistTest, Commit, Tag, MakeDist, UploadCPAN
