http://qs321.pair.com?node_id=906400


in reply to Re: Simplest Possible Way To Disable Unicode
in thread Simplest Possible Way To Disable Unicode

I don't see when use bytes; would possibly be useful to solve this issue. Instead of print warning and returning the possibly useful UTF-8 encoding of the input, it simply destroys the high bits of the bad data.

$ perl -we'use bytes; $_ = chr(1000); print;' | od -t x1 0000000 e8 0000001 $ perl -we'use bytes; $_ = chr(232); print;' | od -t x1 0000000 e8 0000001

Whereas the original situation had a chance of providing something useful, this isn't the case with use bytes;. It possibly make things worse and hides the error.

Replies are listed 'Best First'.
Re^3: Simplest Possible Way To Disable Unicode
by tchrist (Pilgrim) on May 24, 2011 at 18:23 UTC
    I don't see when use bytes; would possibly be useful to solve this issue.
    Agreed. It’s not even clear to me what sort of problem it would solve.

    I’ve never been fond of od output myself. And you shouldn’t need it, either. This tells the story clearly enough:

    % perl -wle 'print ord do { use bytes; chr(1000) }' 232 % perl -wle 'print ord do { use bytes; chr(232) }' 232 % perl -wle 'print ord do { no bytes; chr(1000) }' 1000