in reply to Re^8: Correct Perl settings for sending zipfile to browser
in thread Correct Perl settings for sending zipfile to browser
That is because the source of the "wide characters" is embedded in the code itself, and is not brought in from an external file which must be opened.
The source of the warnings is most likely that some string in your Perl program contains Unicode characters that you are trying to output through a stream that is not set to the proper encoding. Those characters can get there in a number of different ways: a file, a value submitted on an HTML form, from the database, or a Perl string such as the one I showed above - no use utf8 necessary.
That would silence the false alarm.
It's not a false alarm - something really is wrong. It may seem to work for now, but it's possible that if a user with a browser different from yours visits your site, things may break in mysterious ways.
Adding the "use open qw/:std :utf8/;" pragma did not remove the useless warning.
That could mean that it's some other output stream, or possibly that some module reset STDOUT back to the default, and you might have to do an e.g. binmode STDOUT, ':raw:encoding(UTF-8)'; at runtime.
I have tested the code both with and without those characters in that HTML header, and removing them is the only way to erase the error message.
As I said, a SSCCE would be helpful in demonstrating that to us, if you'd like help with that.
The "use utf8;" pragma should be unnecessary. It should be the built-in default.
Yes, that's certainly a very valid argument, and one that others have raised. Perl has a long history of backwards-compatibility though, so (unfortunately) it's unlikely to be changed.
It may be worth noting that I have already required UTF8 for the HTML form, and have specified it in the output
Yes, that's good (except utf8 is not a valid lang, it should probably be en or whatever language your page is in). You could also specify it in the HTTP headers (e.g. by supplying -charset=>'UTF-8' to CGI::Simple's header method).
|
|---|