You can clone with
HTTPS or Subversion.
% perl5i -E 'use CGI::Simple; say CGI::Simple->VERSION'
utf8 "\xF1" does not map to Unicode at /usr/local/app/perl-5.12.1/lib/site_perl/5.12.1/CGI/Simple.pm line 474.
perl5i output warnings when require module contains non-utf8 chars.
more pointed code is following:
% perl -e 'print "package F;\n # \xF1\n;1;"' > x.pl
% perl5i -e 'require "x.pl"'
utf8 "\xF1" does not map to Unicode at x.pl line 1.
This code is not output warnings with plain perl5 interpreter.
% perl -e 'require "x.pl"'
There is a non-UTF8 character in there, but its in a comment way far away (España).
Anyhow, perl -wle 'use utf8; use warnings; use CGI::Simple doesn't provoke the warning. It shouldn't, utf8 should be lexical. Something perl5i is doing is letting it out of its box.
perl -wle 'use utf8; use warnings; use CGI::Simple
And now it is utf8::all that's doing something wrong.
Use :utf8 PerlIO layer instead of :encoding(UTF-8)
This is the non-strict version of the encoding, which silences
the warnings reported in evalEmpire/perl5i#163 and doherty/utfu-all#5
The bug is not in utf8::all but in perl itself. It seems require is affected by the open pragma, as can be seen in this example:
perl '-Mopen=:encoding(utf8)' -e 'require "x.pl"'
I'm not sure how to solve this (other than in perl 5.15.x)
This was discussed at some point on p5p. I meant to ask if there was a workaround older Perls could use, but I don't think I ever did. I should check who was talking about this and get in touch with them about it.
Yes, using the :utf8 layer would work - however it's both the wrong way to solve the issue and also unsafe. I think the Perl bug was fixed, but I'm not sure if it was (or even can be) fixed in older Perls somehow. I'm open to advice on whether the hacky thing is the right way to do it.
The bug was fixed in core in 639dfab029, but that doesn't help users of perl < 5.15. You could do some trick with an OP check function, but I'm not sure that's worth it. Doing :utf8 is probably even be more undesirable though.