in reply to Re^2: issue with Encode::Guess
in thread issue with Encode::Guess

This code:

my $encodings_test = 'ascii cp1252 cp437 cp850 iso-8859-1 utf-8-strict + utf8'; my $decoder = guess_encoding($data, qw/$encodings_test/); print "decoder: $decoder\n";

... does not what you think it does. qw does not interpolate strings into lists. You likely want:

my @encodings_test = qw(ascii cp1252 cp437 cp850 iso-8859-1 utf-8-stri +ct utf8); my $decoder = guess_encoding($data, @encodings_test);

... or if you want to keep your list of encodings as a string (why?!), split it into a list:

my $encodings_test = 'ascii cp1252 cp437 cp850 iso-8859-1 utf-8-strict + utf8'; my @encodings_test = split /\s+/, $encodings_test; my $decoder = guess_encoding($data, @encodings_test); print "decoder: $decoder\n";

Replies are listed 'Best First'.
Re^4: issue with Encode::Guess
by ikegami (Patriarch) on Apr 06, 2020 at 14:08 UTC

    or if you want to keep your list of encodings as a string

    It could come from a config file.

Re^4: issue with Encode::Guess
by toohoo (Beadle) on Apr 06, 2020 at 04:46 UTC

    Hello @Corion,

    This was exactly the point that did lack. Now it works.

    Many thanks for your help.