in reply to can not use utf8 with File::Slurp

Encode::_utf8_off($ustr);
is the wrong way of doing
utf8::encode($ustr);

Replies are listed 'Best First'.
Re^2: can not use utf8 with File::Slurp
by vkon (Curate) on Feb 15, 2011 at 21:03 UTC
    never heard of this, thanks for pointing out.

    Indeed, use Encode; then Encode::_utf8_off to only reset UTF8 bit - is overkill.

      I didn't say it was overkill; I said it was wrong. It is not the purpose of _utf8_off to encode to UTF-8, and it will only do so for some inputs.
        When I used Encode::_utf8_off I only intended to turn UTF8 bit off, without any reencoding, so to avoid "wide char" error

        As far as I see, utf8::encode($foo) also simply turns UTF8 bit off, so effect of these two calls is the same,
        (unless I am misunderstandiong)

        Yet 'Encode' module is huge, so it is overkill also.