[Catalyst] Catalyst Unicode

Christian Lackas christian at lackas.net
Fri Jan 31 11:53:55 GMT 2014


* Christian Lackas <christian at lackas.net> [140131 06:33]:

Hi Everybody,

sorry, has to be 

    $t = $encoding->decode($t);

below, of course (and then it works in the test).
That said, in my application I have:

    my $file = $c->request->param('file');
    warn "is_utf8: ", utf8::is_utf8($file), "\n";

and see that $file has not been decoded to UTF-8, although debug lines
in _handle_param_unicode_decoding() show that the value is passed
through there.

What else could cause this issue here?

Christian

-- 
Dr. Christian Lackas, Managing Partner
inviCRO, LLC -- In Imaging Yours
P: +1 617 963 0263, F: +49 2203 9034722, E: lackas at invicro.com
http://www.invicro.com/  http://www.spect-ct.com/

> Hi Everybody,
> 
> I noticed that paramters in my Catalyst application are not
> automatically decoded to UTF-8, although I use 
> 
>     use Catalyst qw/
>         ...
>         Unicode::Encoding
>         ...
>     /;
>     __PACKAGE__->config(
>         ...
>         encoding => 'UTF-8',
>         ...
>     );
> 
> I tracked this down to Catalyst::Plugin::Unicode::Encoding::\
> _handle_param_unicode_decoding() where I find the line
> 
>     $enc->decode($value, $CHECK)
> 
> that does not seem to have the (my) expected outcome.
> 
> Here is a small test script:
> 
>     #!perl -w
>     use strict;
>     use Encode;
>     my $encoding = Encode::find_encoding("UTF-8");
>     warn "Encoding: $encoding\n";
>     my $t = "Ümläuts";
>     warn "Is utf8: ", Encode::is_utf8($t), " ", utf8::is_utf8($t), "\n";
>     $encoding->decode($t);
>     # utf8::decode($t);
>     warn "Is utf8: ", Encode::is_utf8($t), " ", utf8::is_utf8($t), "\n";
>     binmode STDOUT, ':utf8';
>     print "T=$t\n";
> ------
>     $ perl enc.pl 
>     Encoding: Encode::utf8=HASH(0x1994cb8)
>     Is utf8:  
>     Is utf8:  
>     T=Ümläuts
> 
> When I replace above '$encoding->decode($t)' with 'utf8::decode($t)'
> then it works as expected:
> 
>     $ perl enc.pl 
>     Encoding: Encode::utf8=HASH(0x1e02cb8)
>     Is utf8:  
>     Is utf8: 1 1
>     T=Ümläuts
> 
> What am I doing wrong here? Or do I misunderstand what this code should
> do? Any hints are highly appreciated. Thanks.
> 
> Christian
> 
> -- 
> Dr. Christian Lackas, Managing Partner
> inviCRO, LLC -- In Imaging Yours
> P: +1 617 963 0263, F: +49 2203 9034722, E: lackas at invicro.com
> http://www.invicro.com/  http://www.spect-ct.com/
> 
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/



More information about the Catalyst mailing list