in reply to Simplest Possible Way To Disable Unicode
So to silence the warning, use$ perl -e " print chr(999) " Wide character in print at -e line 1. ϧ $ perl -e " binmode STDOUT; print chr(999) " Wide character in print at -e line 1. ϧ $ perl -Mdiagnostics -e " print chr(999) " Wide character in print at -e line 1 (#1) (S utf8) Perl met a wide character (>255) when it wasn't expecting one. This warning is by default on for I/O (like print). The eas +iest way to quiet this warning is simply to add the :utf8 layer to the output, e.g. binmode STDOUT, ':utf8'. Another way to turn off the warning is to add no warnings 'utf8'; but that is often closer to cheating. In general, you are supposed to explicitly mark the filehandle with an encoding, see open and perlfunc/binmode. ϧ
using bytes would also silence it, but would change the semantics$ perl -e " no warnings q[utf8]; print chr(999) " ϧ
perluniintro, perlunicode$ perl -e " use bytes; print chr(999) " τ
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Simplest Possible Way To Disable Unicode
by ikegami (Patriarch) on May 24, 2011 at 00:37 UTC | |
by Anonymous Monk on May 24, 2011 at 00:59 UTC | |
by ikegami (Patriarch) on May 24, 2011 at 01:00 UTC | |
by Anonymous Monk on May 24, 2011 at 01:05 UTC | |
by ikegami (Patriarch) on May 24, 2011 at 01:31 UTC | |
Re^2: Simplest Possible Way To Disable Unicode
by ikegami (Patriarch) on May 24, 2011 at 01:21 UTC | |
by tchrist (Pilgrim) on May 24, 2011 at 18:23 UTC |
In Section
Seekers of Perl Wisdom