Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

is_utf8をやめる

  • Loading branch information...
commit 70c6554c21f53b65aa500757c89fd72f858c4424 1 parent 63bb658
Atsushi Kobayashi authored
Showing with 12 additions and 17 deletions.
  1. +12 −17 lib/Kamui/Plugin/Mobile/Encode.pm
29 lib/Kamui/Plugin/Mobile/Encode.pm
View
@@ -4,7 +4,6 @@ use base 'Kamui::Plugin';
use Data::Visitor::Encode;
use Encode ();
use Encode::JP::Mobile ();
-use Scalar::Util ();
sub register_method {
+{
@@ -21,28 +20,24 @@ sub register_method {
if ( $res && $res->status == 200
&& $res->content_type =~ /html/
- && not( Scalar::Util::blessed( $res->body ) )
&& $res->body )
{
my $body = $res->body;
+ $res->body( Encode::encode( $c->mobile->encoding, $body ) );
- if (Encode::is_utf8( $body )) {
- $res->body( Encode::encode( $c->mobile->encoding, $body ) );
-
- my $content_type = $res->content_type || 'text/html';
- if ($content_type =~ m!^text/!) {
- my $charset = $c->mobile->can_display_utf8 ? 'UTF-8' : 'Shift_JIS';
- unless ($content_type =~ s/charset\s*=\s*[^\s]*;?/charset=$charset/ ) {
- $content_type .= '; ' unless $content_type =~ /;\s*$/;
- $content_type .= "charset=$charset";
- }
- if ( $content_type =~ m!^text/html!) {
- if ( $c->mobile->is_docomo && $c->mobile->xhtml_compliant ) {
- $content_type =~ s!text/html!application/xhtml+xml!;
- }
+ my $content_type = $res->content_type || 'text/html';
+ if ($content_type =~ m!^text/!) {
+ my $charset = $c->mobile->can_display_utf8 ? 'UTF-8' : 'Shift_JIS';
+ unless ($content_type =~ s/charset\s*=\s*[^\s]*;?/charset=$charset/ ) {
+ $content_type .= '; ' unless $content_type =~ /;\s*$/;
+ $content_type .= "charset=$charset";
+ }
+ if ( $content_type =~ m!^text/html!) {
+ if ( $c->mobile->is_docomo && $c->mobile->xhtml_compliant ) {
+ $content_type =~ s!text/html!application/xhtml+xml!;
}
- $res->content_type( $content_type );
}
+ $res->content_type( $content_type );
}
}
},
Please sign in to comment.
Something went wrong with that request. Please try again.