in reply to Re^4: convert files to ansi (8859-1)
in thread convert files to ansi (8859-1)

-- if we get an error, then i simply say it's utf8 and I don't do anything

That's wrong.

If your input is bytes that are a valid UTF-8 sequence, you still need to call decode on it to have usable strings in Perl.

Replies are listed 'Best First'.
Re^6: convert files to ansi (8859-1)
by Yaerox (Scribe) on Mar 29, 2017 at 08:39 UTC
    Okay. So perl works internal using single-byte code?

    But why does eval decode iso-8859-1 don't throw an error if the input file is utf8?

      Every file is valid ISO-8859-1, because ISO-8859-1 is a single-byte encoding.

        Well, that explains alot ... so I need to look for another way to validate the encoding. Is there any known way to do this?

        I read about Encode::Guess, maybe I have to take a look on it?