|Keep It Simple, Stupid|
Re: how do you turn off the following warning: wide character in print script.pl line 12by jkahn (Friar)
|on May 05, 2003 at 21:04 UTC||Need Help??|
I raised what I'm guessing are some related problems in Setting UTF-8 mode on filehandle reads? a few months back. The best responses are from Re: Setting UTF-8 mode on filehandle reads? and Re: Setting UTF-8 mode on filehandle reads? from diotalevi and grantm respectively. (May their tribes increase.)
I have a version of 5.8 now (hurray for getting off Windows!), and I wrote a little test script in 5.8 to see how one can get away with pushing encoding methods:
Here's the results, when checked with od:
I recognize this isn't exactly what you were asking, but I suspect that the utf8 pragma and the :utf8 encoding layer are getting mixed up somewhere in your code -- one or another is missing, etc.
More specifically, it sounds like you're trying to print a character with a chr value larger than 0xff on a Latin-1 filehandle. Those characters, aren't encodable like that, so you're running the risk of losing data. This is a problem and I encourage you to track it down. Turning off a warning isn't the same as fixing the cause of one.
It might help if you would post a snippet that exhibits the warning. Warnings are usually there for a reason, and perhaps there's something in your code that is a bit sketchy from the compiler's point-of-view.
Hope that helps.
Update: I've just noticed that Perl's coping behavior for characters greater than 0xff on a non-utf8 output filehandle is to print the utf-8 encoding of that character anyway: note that the last two bytes before the newline in both examples are d9 81.
No wonder you get a warning. There's no systematic way to recover whether the output data was originally UTF-8 or not!
Update 2: Cleaned up comments by using the word "encoded" instead of "printed".