X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FPlugin%2FUnicode%2FEncoding.pm;h=022efd2b5c1330a420ee35da05caa2be77cf161f;hb=65905d68f5081a6eaf392e6ef3a84b63e2a04701;hp=2f2e8d5636941d79f0a51600e27b61f2e59f1938;hpb=f20ba798d3cd91a5df5a0fc1f18c2947348a2b93;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Plugin/Unicode/Encoding.pm b/lib/Catalyst/Plugin/Unicode/Encoding.pm index 2f2e8d5..022efd2 100644 --- a/lib/Catalyst/Plugin/Unicode/Encoding.pm +++ b/lib/Catalyst/Plugin/Unicode/Encoding.pm @@ -23,6 +23,10 @@ sub encoding { if (my $wanted = shift) { $encoding = Encode::find_encoding($wanted) or Carp::croak( qq/Unknown encoding '$wanted'/ ); + binmode(STDERR, ':encoding(' . $encoding->name . ')'); + } + else { + binmode(STDERR); } $encoding = ref $c @@ -81,6 +85,7 @@ sub prepare_uploads { $c->next::method(@_); my $enc = $c->encoding; + return unless $enc; for my $key (qw/ parameters query_parameters body_parameters /) { for my $value ( values %{ $c->request->{$key} } ) { @@ -114,6 +119,9 @@ sub prepare_action { my $ret = $c->next::method(@_); + my $enc = $c->encoding; + return $ret unless $enc; + foreach (@{$c->req->arguments}, @{$c->req->captures}) { $_ = $c->_handle_param_unicode_decoding($_); } @@ -126,12 +134,12 @@ sub setup { my $conf = $self->config; - # Allow an explict undef encoding to disable default of utf-8 + # Allow an explicit undef encoding to disable default of utf-8 my $enc = delete $conf->{encoding}; $self->encoding( $enc ); return $self->next::method(@_) - unless $self->setup_finished; ## hack to stop possibily meaningless test fail... (jnap) + unless $self->setup_finished; ## hack to stop possibly meaningless test fail... (jnap) } sub _handle_unicode_decoding { @@ -197,7 +205,7 @@ Catalyst::Plugin::Unicode::Encoding - Unicode aware Catalyst This plugin is automatically loaded by apps. Even though is not a core component yet, it will vanish as soon as the code is fully integrated. For more -information, please refer to C section at L. +information, please refer to L. =head1 AUTHORS