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


in reply to Re^2: utf file to ansi, but doesn't work?
in thread utf file to ansi, but doesn't work?

Is there a simple way I can check the header (i.e "type") of a file?

There isn't in general any such thing. All there is in a text file is what you see; that's what makes it text. UTF-x files can (and sometimes must) have a BOM, but ISO-8859's won't.

Your text editor either has to be told (by you, by default config, etc) what encoding to use, or it can try (and occasionally even succeed) to guess by the patterns of bytes in it. But it has no way to be know unless you tell it. That's why text encoding is such a mess...