http://www.perlmonks.org?node_id=906507


in reply to Simplest Possible Way To Disable Unicode

Assuming you are not yourself causing the packing of too much into a byte anywhere, in which case the warning is IMO fair, (like the chr(999) example cited), you could overload syswrite to unpack the data into bytes before invoking the real syswrite or failing that have a warning-free module that does nothing more than that.

One world, one people

Replies are listed 'Best First'.
Re^2: Simplest Possible Way To Disable Unicode
by tchrist (Pilgrim) on May 24, 2011 at 19:08 UTC
    ... you could overload syswrite to unpack the data into bytes before invoking the real syswrite...
    Which is just what encoding layers exist for:
    % perl -C0 -we 'syswrite(STDOUT, chr(0x500), 1)' | wc -c Wide character in syswrite at -e line 1. 0 Exit 255 % perl -CS -we 'syswrite(STDOUT, chr(0xE9), 1)' | wc -c 2 % perl -CS -we 'syswrite(STDOUT, chr(0x1000), 1)' | wc -c 3 % perl -CS -we 'syswrite(STDOUT, chr(0x01_0000), 1)' | wc -c 4 % perl -CS -we 'syswrite(STDOUT, chr(0x0100_0000), 1)' | wc -c 5 % perl -CS -we 'syswrite(STDOUT, chr(0x1000_0000), 1)' | wc -c 6 % perl -CS -we 'syswrite(STDOUT, chr(0xF000_0000), 1)' | wc -c 7 % perl -CS -M-warnings=portable -we 'syswrite(STDOUT, chr(0x10_0000_00 +00), 1)' | wc -c 13