[Catalyst] Patch for Catalyst::Plugin::Unicode::Encoding

Jonas Alves jonas.alves at gmail.com
Wed Mar 19 00:04:37 GMT 2008


On Tue, Mar 18, 2008 at 11:01 AM, Bill Moseley <moseley at hank.org> wrote:
> On Tue, Mar 18, 2008 at 03:38:06AM -0500, Jonathan Rockway wrote:
>  > * On Tue, Mar 18 2008, Bill Moseley wrote:
>  > > The plugin decodes all parameters using:
>  > >
>  > >     $_ = $c->encoding->decode( $_, $CHECK ) for ( ref($value) ? @{$value} : $value );
>  > >
>  > >
>  > > I'd think it would be wise to check to see if the string is already
>  > > decoded:
>  > >
>  > >     for ( ref($value) ? @{$value} : $value ) {
>  > >         next if Encode::is_utf8($_);
>  > >         $_ = $c->encoding->decode( $_, $CHECK );
>  > >     }
>  >
>  > Never check is_utf8.  Encode will do the right thing regardless of
>  > the internal representation of the string.
>  >
>
>  This is decoding, not encoding.
>
>  Without testing is_utf8 and if the parameters are already decoded I
>  rightly get:
>
>     [error] Caught exception in engine "Cannot decode string with wide
>     characters at
>     /usr/local/share/perl/5.8.8/Catalyst/Plugin/Unicode/Encoding.pm
>     line 74."
>
>
>
>  >   http://blog.jrock.us/articles/Fuck%20the%20internal%20representation.pod
>
>  Yes, checking is_ut8 before encoding doesn't make sense.
>
>

No, you never should check the flag. See Miyagawa's post
http://use.perl.org/~miyagawa/journal/35700.

-- 
Jonas



More information about the Catalyst mailing list