* David Schmidt <[email protected]> [140131 06:53]: Dear David,
thanks for your prompt reply. If I use 'use utf8', I already tell Perl that all literals are in UTF-8, and thus would not need to decode manually at all (as you see in your output it already says is_utf8 even before you decode manually). What I tried to simulate is: I have some text in a variable, and I know its UTF-8, however, Perl does not, yet, thus I have to decode it. Please also note the small error I made with not taking the return value of '$encoding->decode()'. Christian -- Dr. Christian Lackas, Managing Partner inviCRO, LLC -- In Imaging Yours P: +1 617 963 0263, F: +49 2203 9034722, E: [email protected] http://www.invicro.com/ http://www.spect-ct.com/ > https://metacpan.org/pod/release/JJNAPIORK/Catalyst-Runtime-5.90053/lib/Catalyst/Upgrading.pod#Catalyst::Plugin::Unicode::Encoding-is-now-core > > > and in your test script, im pretty sure if you are using unicode chars > in your perl code you have to "use utf8" in it. > > also, "use warnings" instead of "perl -w" > > #!/usr/bin/env perl > use strict; > use warnings; > use utf8; > 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"; > > > david@nio:~$ perl foo.pl > Encoding: Encode::utf8=HASH(0x1f22390) > Is utf8: 1 1 > Is utf8: > T=Ümläuts > > On 31 January 2014 12:29, Christian Lackas <[email protected]> wrote: > > 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: [email protected] > > http://www.invicro.com/ http://www.spect-ct.com/ > > > > _______________________________________________ > > List: [email protected] > > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > > Searchable archive: http://www.mail-archive.com/[email protected]/ > > Dev site: http://dev.catalyst.perl.org/ > > _______________________________________________ > List: [email protected] > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > Searchable archive: http://www.mail-archive.com/[email protected]/ > Dev site: http://dev.catalyst.perl.org/ _______________________________________________ List: [email protected] Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[email protected]/ Dev site: http://dev.catalyst.perl.org/
