Changeset 10020
- Timestamp:
- 04/20/08 23:21:48 (5 years ago)
- Location:
- lang/perl/Moxy/trunk/lib
- Files:
-
- 5 modified
-
Moxy.pm (modified) (2 diffs)
-
Moxy/Plugin/ControlPanel.pm (modified) (1 diff)
-
Moxy/Plugin/LocationBar.pm (modified) (1 diff)
-
Moxy/Plugin/Pictogram.pm (modified) (1 diff)
-
Moxy/Util.pm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Moxy/trunk/lib/Moxy.pm
r10012 r10020 27 27 use YAML; 28 28 use HTML::TreeBuilder; 29 use Moxy::Util; 29 30 use HTML::TreeBuilder::XPath; 30 31 use HTTP::MobileAttribute plugins => [ … … 235 236 $self->log("Content-Type: $content_type"); 236 237 if ($content_type =~ /html/i) { 237 $res->content( rewrite($base_url, $res->content, $url) );238 $res->content( encode($res->charset, rewrite($base_url, decode($res->charset, $res->content), $url)) ); 238 239 } 239 240 use bytes; -
lang/perl/Moxy/trunk/lib/Moxy/Plugin/ControlPanel.pm
r10004 r10020 20 20 21 21 # convert html charset to response charset. 22 my $charset = Moxy::Util->detect_charset($args->{response});22 my $charset = $args->{response}->charset; 23 23 my $enc = Encode::find_encoding($charset); 24 24 Encode::from_to($output, 'utf-8', $enc ? $enc->name : 'utf-8'); -
lang/perl/Moxy/trunk/lib/Moxy/Plugin/LocationBar.pm
r10016 r10020 18 18 return sprintf(<<"...", encode_entities($current_url)); 19 19 <script> 20 var moxy_base = location.protocol + '://' + location.host;20 var moxy_base = location.protocol.replace(':', '') + '://' + location.host; 21 21 </script> 22 22 <form method="get" onsubmit="location.href=moxy_base +'/'+encodeURIComponent(document.getElementById('moxy_url').value);return false;"> -
lang/perl/Moxy/trunk/lib/Moxy/Plugin/Pictogram.pm
r10004 r10020 15 15 my $carrier = $args->{mobile_attribute}->carrier; 16 16 17 my $charset = 18 Moxy::Util->detect_charset( $args->{response} ); 17 my $charset = $args->{response}->charset; 19 18 $charset = ( $charset =~ /utf-?8/i ) ? 'utf8' : 'sjis'; 20 19 -
lang/perl/Moxy/trunk/lib/Moxy/Util.pm
r9968 r10020 22 22 } 23 23 24 sub detect_charset {25 my ($ class, $response) = @_;24 sub HTTP::Response::charset { 25 my ($self, ) = @_; 26 26 27 my $charset; 28 if ($response->header('Content-Type') =~ /charset=([\w\-]+)/io) { 29 $charset = $1; 30 } 31 $charset ||= ( $response->content() =~ /<\?xml version="1.0" encoding="([\w\-]+)"\?>/ )[0]; 32 $charset ||= ( $response->content() =~ m!<meta http-equiv="Content-Type" content=".*charset=([\w\-]+)"!i )[0]; 33 $charset ||= $Detector->($response->content()); 34 $charset ||= 'utf-8'; 35 36 return $charset; 27 return $self->{__charset} ||= do { 28 my $charset; 29 if ( $self->header('Content-Type') =~ /charset=([\w\-]+)/io ) { 30 $charset = $1; 31 } 32 $charset ||= ( $self->content() =~ /<\?xml version="1.0" encoding="([\w\-]+)"\?>/ )[0]; 33 $charset ||= ( $self->content() =~ m!<meta http-equiv="Content-Type" content=".*charset=([\w\-]+)"!i)[0]; 34 $charset ||= $Detector->( $self->content() ); 35 $charset ||= 'cp932'; 36 $charset; 37 }; 37 38 } 38 39
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)