user2000 has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am having a slight problem while using LWP. On discussion with Bart, we have boiled down to the following:

Original Page: http://www.inscripts.com/?privacypolicy Encoding: ISO-8859-1 (as per firefox page info)

I use lwp to get the page and print it immediately using print $response->content;

However after viewing the page in firefox the encoding type is : utf-8

I have tried placing binmode STDOUT; before the print statement but its still not working.

Thank you very much, Anant

Replies are listed 'Best First'.
Re: lwp encoding problem
by moritz (Cardinal) on Aug 26, 2007 at 11:26 UTC
Re: lwp encoding problem
by Gangabass (Vicar) on Aug 26, 2007 at 13:48 UTC

    You need to remove wrong HTML header:

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    before printing

    Something like this:

    my $page = $response->content; $page =~ s{<meta http-equiv="Content-Type" content="text/html; charset +=utf-8" />}{<meta http-equiv="Content-Type" content="iso-8859-1" />}; print $page;
Re: lwp encoding problem
by Anonymous Monk on Aug 26, 2007 at 11:27 UTC
    lets turn our brains off together :)
    <META NAME="DESCRIPTION" CONTENT="Inscripts aim to give you the techno +logy, the solution and the edge so that you can spend your time doing + what you do best, running your business."> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Inscripts | Privacy Policy </title> <style type="text/css">
      And the server sends a latin1 header:

      $ wget --server-response http://www.inscripts.com/?privacypolicy 2>&1| +grep charset Content-Type: text/html; charset=iso-8859-1
        yes that the exact problem. how should i print the server returned content-type using lwp?