in reply to HTML parsing module handles known and unknown encoding
XML parsers should expect encoded documents since the encoding is specified in the document itself. This is what XML::LibXML expects. (Even when using the HTML parsing methods, which is problematic.)
HTML parsers should expect decoded documents since the encoding is not specified in the document itself. You are clearly dealing with HTML since you mention "HTTP header".
And that's where you should be looking, in the tool that handles the HTTP transfer. $response->decoded_content() will decode the HTML for you, based on the HTTP header, BOM and META elements (if HTML).
The default charset decoded_content uses is is iso-8859-1, but you can can change it to cp1252 by passing default_charset => 'cp1252' as arguments to decoded_content.
my $decoded_html = $response->decoded_content(default_charset => 'cp12 +52');
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: HTML parsing module handles known and unknown encoding
by ambrus (Abbot) on Nov 17, 2011 at 07:05 UTC | |
by ikegami (Patriarch) on Nov 17, 2011 at 09:04 UTC |