HTTP-Message
view release on metacpan or search on metacpan
lib/HTTP/Message.pm view on Meta::CPAN
sub content_charset
{
my $self = shift;
if (my $charset = $self->content_type_charset) {
return $charset;
}
# time to start guessing
my $cref = $self->decoded_content(ref => 1, charset => "none");
# Unicode BOM
for ($$cref) {
return "UTF-8" if /^\xEF\xBB\xBF/;
return "UTF-32LE" if /^\xFF\xFE\x00\x00/;
return "UTF-32BE" if /^\x00\x00\xFE\xFF/;
return "UTF-16LE" if /^\xFF\xFE/;
return "UTF-16BE" if /^\xFE\xFF/;
}
if ($self->content_is_xml) {
# http://www.w3.org/TR/2006/REC-xml-20060816/#sec-guessing
( run in 0.674 second using v1.01-cache-2.11-cpan-e9daa2b36ef )