Re: Doing character encoding/decoding within libwww?

Bill Moseley <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <[email protected]>
On Sat, Sep 22, 2007 at 11:50:53PM +0200, Bjoern Hoehrmann wrote:
> * Bill Moseley wrote:
> >On Fri, Sep 21, 2007 at 12:49:26PM -0700, David Nesting wrote:
> >> For most uses of libwww, developers do little with character encoding.
> >> Indeed, for general-case use of LWP::Simple, they can't, because that
> >> information isn't even exposed.  Has any thought gone into doing this
> >> internally within libwww, so that when I fetch content, I get back text
> >> instead of octets?
> >
> >If you have the response object:
> >
> >    $response->decoded_content;
> 
> That removes content encodings like gzip and deflate, but David is
> asking about character encodings like utf-8 and iso-8859-1. Content
> encodings are applied after character encodings.

sub decoded_content {
    ....

    $content_ref = \Encode::decode($charset, $$content_ref,
                                   Encode::FB_CROAK() | Encode::LEAVE_SRC());

-- 
Bill Moseley
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.