However, in the real world, you'll often find that HTML documents are served over HTTP where the HTTP headers don't tell the encoding of the document.
You appear to have missed crucial information in my post. Like I said, $response->decoded_content() will decode the HTML for you, based on the HTTP header, BOM and META elements (if HTML).
In that case, you'll need a way to find the encoding from the document itself. A HTML parser should support both of these cases.
Sure, though I'm not familiar with an HTML parser that supports both.