When HTML::Parser opens a file, at the top of the file one of the first things should be a header that specifies the encoding. HTML::Parser has to switch it's encoding according to the header or it would strongly fail alot of parsing out there. Switching decoding on the fly is a requirement of HTML Parsers.