in reply to Re^2: How to know to know if string is utf8 encoded or decoded.
in thread How to know to know if string is utf8 encoded or decoded.

Wrapping the code in eval only makes sense if you ask decode to die if it can't decode:
eval { $unicode = Encode::decode($from,$str,Encode::FB_CROAK); }; if ($@) { &ConvertEncodingError("($from -> utf8)\n$@"); return $str; }
You should be aware that in case of a decoding error, $str will be overwritten.

Replies are listed 'Best First'.
Re^4: How to know to know if string is utf8 encoded or decoded.
by ikegami (Patriarch) on Jul 29, 2019 at 05:54 UTC

    The third arg needs to be Encode::FB::CROAK | Encode::LEAVE_SRC since you don't want $from to change.