Index: /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/t/02_fallback.t
===================================================================
--- /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/t/02_fallback.t (revision 14585)
+++ /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/t/02_fallback.t (revision 14585)
@@ -0,0 +1,48 @@
+use strict;
+use Test::More tests => 3;
+
+package TestApp;
+use Catalyst qw(
+    MobileAgent
+    Unicode::Encoding::JP::Mobile
+);
+
+__PACKAGE__->setup;
+
+sub mixed :Local {
+    my ($self, $c) = @_;
+    use utf8;
+    $c->res->content_type('text/plain');
+    $c->res->body("\x{E6D1}\x{F094}\x{E309}");
+    # [DoCoMoにしかないiモードマーク][auにしかないEZマーク][Softbankにしかないトイレ]
+}
+
+
+package main;
+use Catalyst::Test 'TestApp';
+use Encode;
+use HTTP::Request::Common;
+
+my $res;
+
+$res = request(
+    GET '/mixed', 
+    User_Agent => 'DoCoMo/2.0 SH902i(c100;TB;W24H12)', # xhtml_compliant docomo
+);
+is( $res->content => "\xEE\x9B\x91[EZ][WC]" );
+
+$res = request(
+    GET '/mixed', 
+    User_Agent => 'KDDI-SA31 UP.Browser/6.2.0.6.3.129 (GUI) MMP/2.0', # au
+);
+is( $res->content => do {
+    my $i = '［ｉモード］';
+    Encode::from_to($i, 'utf-8', 'shift_jis');
+    "$i\xF7\x94[WC]";
+});
+
+$res = request(
+    GET '/mixed', 
+    User_Agent => 'SoftBank/1.0/821T/TJ001/SN*************** Browser/NetFront/3.3', # 3gc softbank
+);
+is( $res->content => "［ｉモード］[EZ]\xEE\x8C\x89" );
Index: /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/t/98_perlcritic.t
===================================================================
--- /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/t/98_perlcritic.t (revision 14585)
+++ /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/t/98_perlcritic.t (revision 14585)
@@ -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-Plugin-Unicode-Encoding-JP-Mobile/trunk/t/97_podspell.t
===================================================================
--- /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/t/97_podspell.t (revision 14585)
+++ /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/t/97_podspell.t (revision 14585)
@@ -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
+Catalyst::Plugin::Unicode::Encoding::JP::Mobile
+UTF-8
Index: /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/t/99_pod.t
===================================================================
--- /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/t/99_pod.t (revision 14585)
+++ /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/t/99_pod.t (revision 14585)
@@ -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-Plugin-Unicode-Encoding-JP-Mobile/trunk/t/01_decode-parameters.t
===================================================================
--- /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/t/01_decode-parameters.t (revision 14585)
+++ /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/t/01_decode-parameters.t (revision 14585)
@@ -0,0 +1,73 @@
+use strict;
+use Test::More tests => 6;
+
+package TestApp;
+use Catalyst qw(
+    MobileAgent
+    Unicode::Encoding::JP::Mobile
+);
+
+__PACKAGE__->setup;
+
+use Encode;
+
+sub decoded_param :Local {
+    my ($self, $c) = @_;
+    $c->res->content_type('text/plain');
+    $c->res->body(
+        $c->encoding->name . '/' .
+        encode('ascii', $c->req->param('text'), Encode::FB_XMLCREF)
+    );
+}
+
+
+package main;
+use Catalyst::Test 'TestApp';
+use HTTP::Request::Common;
+
+my $res;
+
+$res = request(
+    POST '/decoded_param', 
+    User_Agent => 'DoCoMo/2.0 SH902i(c100;TB;W24H12)', # xhtml_compliant docomo
+    Content => [ text => "\xE3\x81\x82\xEE\x98\xBE" ], # [あ][DoCoMoの太陽](utf8)
+);
+is( $res->content => 'x-utf8-docomo/&#x3042;&#xe63e;' );
+
+$res = request(
+    POST '/decoded_param', 
+    User_Agent => 'DoCoMo/1.0/F505i/c20/TB/W20H10', # non xhtml_compliant docomo
+    Content => [ text => "\x82\xA0\xF8\x9F" ], # [あ][DoCoMoの太陽](sjis)
+);
+is( $res->content => 'x-sjis-docomo/&#x3042;&#xe63e;' );
+
+
+$res = request(
+    POST '/decoded_param', 
+    User_Agent => 'KDDI-SA31 UP.Browser/6.2.0.6.3.129 (GUI) MMP/2.0', # au
+    Content => [ text => "\x82\xA0\xF6\x60" ], # [あ][auの太陽](sjis)
+);
+is( $res->content => 'x-sjis-kddi-auto/&#x3042;&#xef60;' );
+
+
+$res = request(
+    POST '/decoded_param', 
+    User_Agent => 'SoftBank/1.0/821T/TJ001/SN*************** Browser/NetFront/3.3', # 3gc softbank
+    Content => [ text => "\xE3\x81\x82\xEE\x81\x8A" ], # [あ][softbankの太陽](utf8)
+);
+is( $res->content => 'x-utf8-softbank/&#x3042;&#xe04a;' );
+
+$res = request(
+    POST '/decoded_param', 
+    User_Agent => 'J-PHONE/2.0/J-T04', # non 3gc softbank 
+    Content => [ text => "\x82\xA0\x1B\x24\x47\x6A\x0F" ], # [あ][softbankの太陽ウェブコード](sjis)
+);
+is( $res->content => 'x-sjis-softbank/&#x3042;&#xe04a;' );
+
+
+$res = request(
+    POST '/decoded_param', 
+    User_Agent => 'Mozilla/5.0', # non mobile 
+    Content => [ text => "\xE3\x81\x82" ], # [あ](utf8)
+);
+is( $res->content => 'utf-8-strict/&#x3042;' );
Index: /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/t/03_fallback-htmlspecialchars.t
===================================================================
--- /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/t/03_fallback-htmlspecialchars.t (revision 14585)
+++ /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/t/03_fallback-htmlspecialchars.t (revision 14585)
@@ -0,0 +1,41 @@
+use strict;
+use Test::More tests => 2;
+
+package TestApp;
+use Catalyst qw(
+    MobileAgent
+    Unicode::Encoding::JP::Mobile
+);
+
+__PACKAGE__->setup;
+
+sub plain :Local {
+    my ($self, $c) = @_;
+    $c->res->content_type('text/plain');
+    $c->res->body("\x{ECA2}"); # auのDoCoMoにない顔 (>３<)
+}
+
+sub html :Local {
+    my ($self, $c) = @_;
+    $c->res->content_type('text/html');
+    $c->res->body("\x{ECA2}"); # auのDoCoMoにない顔 (>３<)
+}
+
+
+package main;
+use Catalyst::Test 'TestApp';
+use HTTP::Request::Common;
+
+my $res;
+
+$res = request(
+    GET '/plain', 
+    User_Agent => 'DoCoMo/2.0 SH902i(c100;TB;W24H12)', # xhtml_compliant docomo
+);
+is( $res->content => '(>３<)' );
+
+$res = request(
+    GET '/html', 
+    User_Agent => 'DoCoMo/2.0 SH902i(c100;TB;W24H12)', # xhtml_compliant docomo
+);
+is( $res->content => '(&gt;３&lt;)' );
Index: /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/t/00_compile.t
===================================================================
--- /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/t/00_compile.t (revision 14585)
+++ /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/t/00_compile.t (revision 14585)
@@ -0,0 +1,4 @@
+use strict;
+use Test::More tests => 1;
+
+BEGIN { use_ok 'Catalyst::Plugin::Unicode::Encoding::JP::Mobile' }
Index: /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/lib/Catalyst/Plugin/Unicode/Encoding/JP/Mobile.pm
===================================================================
--- /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/lib/Catalyst/Plugin/Unicode/Encoding/JP/Mobile.pm (revision 14585)
+++ /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/lib/Catalyst/Plugin/Unicode/Encoding/JP/Mobile.pm (revision 14585)
@@ -0,0 +1,176 @@
+package Catalyst::Plugin::Unicode::Encoding::JP::Mobile;
+use strict;
+use warnings;
+our $VERSION = '0.01';
+
+use Class::C3;
+use Encode;
+use Encode::JP::Mobile ':props';
+use Encode::JP::Mobile::Character;
+use HTTP::MobileAgent::Plugin::Charset;
+
+use base 'Class::Accessor::Fast';
+__PACKAGE__->mk_accessors(qw( encoding ));
+
+sub setup {
+    my $c = shift;
+    
+    if ($c->isa('Catalyst::Plugin::Unicode') or
+        $c->isa('Catalyst::Plugin::Unicode::Encoding') ) {
+        Catalyst::Exception->throw(
+            __PACKAGE__ ." cannot be used with C::P::Unicode or C::P::U::Encoding."
+        );
+    }
+    
+    $c->next::method(@_);
+}
+
+sub prepare_parameters {
+    my $c = shift;
+    
+    $c->next::method(@_);
+    
+    $c->encoding(do {
+        my $encoding = $c->req->mobile_agent->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) {
+            $v = $c->encoding->decode($v);
+        }
+    }
+    
+    $c->res->content_type(do {
+        if ($c->req->mobile_agent->is_docomo) {
+            'application/xhtml+xml';   
+        } else {
+            'text/html; charset=' . $c->encoding->mime_name;
+        }
+    });
+}
+
+my %htmlspecialchars = ( '&' => '&amp;', '<' => '&lt;', '>' => '&gt;', '"' => '&quot;' );
+my $htmlspecialchars = join '', keys %htmlspecialchars;
+
+our $decoding_content_type = qr{^text|xml$|javascript$};
+
+sub finalize_body {
+    my $c = shift;
+    
+    my $body = $c->res->body;
+    if ($body and
+        not ref($body) and
+        $c->res->content_type =~ $decoding_content_type) {
+        
+        $body = $c->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);
+    }
+    
+    $c->next::method(@_);
+}
+
+1;
+__END__
+
+=encoding utf-8
+
+=head1 NAME
+
+Catalyst::Plugin::Unicode::Encoding::JP::Mobile - Handle encodings with Encode::JP::Mobile
+
+=head1 SYNOPSIS
+
+  use Catalyst qw(
+      MobileAgent
+      Unicode::Encoding::JP::Mobile
+  );
+
+=head1 DESCRIPTION
+
+Catalyst::Plugin::Unicode::Encoding::JP::Mobile is a Catalyst plugin
+to handle encodings using L<Encode::JP::Mobile>, especially for 
+Japanese mobile website developers.
+
+L<Catalyst::Plugin::MobileAgent> と同時に利用してください。
+
+=head1 RELATED MODULES
+
+内部で Unicode を使うための他のモジュールとの比較。これらは併用はできません。
+
+=over 4
+
+=item L<Catalyst::Plugin::Unicode>
+
+入出力は UTF-8 固定です。
+
+=item L<Catalyst::Plugin::Unicode::Encoding>
+
+入出力は設定で指定したエンコーディング固定です。
+
+=item Catalyst::Plugin::Unicode::Encoding::JP::Mobile （これです）
+
+入出力は User-Agent の値を元に L<HTTP::MobileAgent::Plugin::Charset> に基づく
+エンコーディングとなります。携帯の場合 L<Encode::JP::Mobile> の中の適したものが
+選ばれ、携帯以外の場合 UTF-8 が使われます。
+
+=back
+
+=head1 EXTENDED ACCESSOR
+
+=over 4
+
+=item encoding
+
+利用されるエンコーディングの L<Encode::Encoding> オブジェクト。
+
+  $c->encoding->name;      # x-sjis-docomo
+  $c->encoding->mime_name; # Shift_JIS
+
+=back
+
+=head1 OVERLOADED METHODS
+
+=over 4
+
+=item prepare_parameters  
+
+$c->encoding をセットし、$c->request->parameters を $c->encoding で Encode::decode() します。
+
+$c->response->content_type をセットします。（必要に応じて Controller で上書きしてください）。
+
+=item finalize_body 
+
+$c->response->content_type が
+C<$Catalyst::Plugin::Unicode::Encoding::JP::Mobile::decoding_content_type> の正規表現に
+マッチする場合 $c->response->body を $c->encoding で encode します。
+その際 L<Encode::JP::Mobile::FB_CHARACTER|Encode::JP::Mobile::Fallback> が使われます。
+
+=back
+
+=head1 AUTHOR
+
+Naoki Tomita E<lt>tomita@cpan.orgE<gt>
+
+=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<Catalyst>, L<Encode::JP::Mobile>, L<HTTP::MobileAgent::Plugin::Charset>
+
+=cut
Index: /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/Makefile.PL
===================================================================
--- /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/Makefile.PL (revision 14585)
+++ /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/Makefile.PL (revision 14585)
@@ -0,0 +1,18 @@
+use inc::Module::Install;
+
+name 'Catalyst-Plugin-Unicode-Encoding-JP-Mobile';
+all_from 'lib/Catalyst/Plugin/Unicode/Encoding/JP/Mobile.pm';
+
+requires 'Catalyst::Runtime'  => '5.70';
+requires 'Encode::JP::Mobile' => '0.25';
+requires 'Class::C3';
+requires 'Encode';
+requires 'HTTP::MobileAgent::Plugin::Charset';
+
+build_requires 'Test::More';
+build_requires 'HTTP::Request::Common';
+build_requires 'Catalyst::Plugin::MobileAgent';
+
+auto_include;
+
+WriteAll;
Index: /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/Changes
===================================================================
--- /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/Changes (revision 14585)
+++ /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/Changes (revision 14585)
@@ -0,0 +1,4 @@
+Revision history for Perl extension Catalyst::Plugin::Unicode::Encoding::JP::Mobile
+
+0.01  Tue Jun 24 16:04:05 JST 2008
+        - original version
Index: /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/MANIFEST.SKIP
===================================================================
--- /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/MANIFEST.SKIP (revision 14585)
+++ /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/MANIFEST.SKIP (revision 14585)
@@ -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-Plugin-Unicode-Encoding-JP-Mobile/trunk/README
===================================================================
--- /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/README (revision 14585)
+++ /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/README (revision 14585)
@@ -0,0 +1,27 @@
+This is Perl module Catalyst::Plugin::Unicode::Encoding::JP::Mobile.
+
+INSTALLATION
+
+Catalyst::Plugin::Unicode::Encoding::JP::Mobile installation is straightforward. If your CPAN shell is set up,
+you should just be able to do
+
+    % cpan Catalyst::Plugin::Unicode::Encoding::JP::Mobile
+
+Download it, unpack it, then build it as per the usual:
+
+    % perl Makefile.PL
+    % make && make test
+
+Then install it:
+
+    % make install
+
+DOCUMENTATION
+
+Catalyst::Plugin::Unicode::Encoding::JP::Mobile documentation is available as in POD. So you can do:
+
+    % perldoc Catalyst::Plugin::Unicode::Encoding::JP::Mobile
+
+to read the documentation online with your favorite pager.
+
+Naoki Tomita
Index: /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/.shipit
===================================================================
--- /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/.shipit (revision 14585)
+++ /lang/perl/Catalyst-Plugin-Unicode-Encoding-JP-Mobile/trunk/.shipit (revision 14585)
@@ -0,0 +1,1 @@
+steps = FindVersion, ChangeVersion, CheckChangeLog, DistTest, Commit, Tag, MakeDist, UploadCPAN
