The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

LWP::Charset - Retrive charset information of a response object.

SYNOPSIS

    use LWP::UserAgent;
    use LWP::Charset qw(getCharset);

    my $ua = LWP::UserAgent->new( timeout => 30 );
    $response = $ua->get('http://search.cpan.org/');

    $charset  = getCharset($response);

    print $charset;

DESCRIPTION

This module help you to determine the charset coding of web pages (type text/plain or text/html).

FUNCTIONS

getCharset($response)

$response: A HTTP::Response object which is_success(). This is a wrapper of getCharsetFromHeader() and getCharsetFromMeta().

getCharsetFromHeader($response)

Look into HTTP header to see if Content-Type containt charset information. Return lowercased charset string or undef if failed.

getCharsetFromMeta($response)

Look into HTML meta tag, to see if there's some charset information. Return lowercased charset string or undef if failed.

getCharsetFromMetaString($string)

An internally used subroutine which accept a string and find meta tags inside, retrive possible charset information. Return lowercased charset string or undef if failed to find any.

COPYRIGHT

Copyright 2003,2004,2005 by Kang-min Liu <gugod@gugod.org>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See <http://www.perl.com/perl/misc/Artistic.html>