[Catalyst] Catalyst Unicode

Christian Lackas christian at lackas.net
Fri Jan 31 11:29:46 GMT 2014


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/



More information about the Catalyst mailing list