Changeset 5601

Show
Ignore:
Timestamp:
01/27/08 09:47:18 (5 years ago)
Author:
tokuhirom
Message:

use HTTP::MobileAgent::Plugin::Charset;

Location:
lang/perl/mobirc/trunk/mobirc
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/mobirc/trunk/mobirc/Makefile.PL

    r5094 r5601  
    3535requires 'CSS::Tiny'; 
    3636requires 'Encode::JP::Mobile'; 
     37requires 'HTTP::MobileAgent::Plugin::Charset'; 
    3738 
    3839features( 
  • lang/perl/mobirc/trunk/mobirc/lib/Mobirc/HTTPD.pm

    r1697 r5601  
    2020use UNIVERSAL::require; 
    2121use HTTP::MobileAgent; 
     22use HTTP::MobileAgent::Plugin::Charset; 
    2223 
    2324use Mobirc; 
  • lang/perl/mobirc/trunk/mobirc/lib/Mobirc/HTTPD/Controller.pm

    r5470 r5601  
    1515use List::Util qw/first/; 
    1616use Template::Provider::Encoding; 
     17use Encode::JP::Mobile 0.24; 
    1718 
    1819use Mobirc; 
     
    128129    my $r       = CGI->new( $c->{req}->content ); 
    129130    my $message = $r->param('msg'); 
    130     $message = decode( _get_charset($c), $message ); 
     131    $message = decode( $c->{mobile_agent}->encoding, $message ); 
    131132 
    132133    DEBUG "POST MESSAGE $message"; 
     
    239240    DEBUG "rendering done"; 
    240241 
    241     my $content = encode( _get_charset($c), $out); 
     242    my $content = encode( $c->{mobile_agent}->encoding, $out); 
    242243    $content = _html_filter($c, $content); 
    243244 
     
    328329} 
    329330 
    330 # FIXME I want to use HTTP::MobileAgent::Plugin::Charset 
    331 sub _get_charset { 
    332     my ($c, ) = @_; 
    333  
    334     my $charset = $c->{config}->{httpd}->{charset} || 'shift_jis-mobile-auto'; 
    335  
    336     if ($charset =~ /^shift_jis-.+/) { 
    337         require Encode::JP::Mobile; 
    338     } 
    339  
    340     if ($charset eq 'shift_jis-mobile-auto') { 
    341         my $agent = $c->{mobile_agent}; 
    342         if ($agent->is_non_mobile) { 
    343             $charset = 'utf8'; 
    344         } else { 
    345             $charset = 'shift_jis-' . lc $agent->carrier_longname; 
    346         } 
    347     } 
    348  
    349     DEBUG "use charset: $charset"; 
    350  
    351     return $charset; 
    352 } 
    353  
    3543311;