+When handed a MIME::Entity will first attempt to read what charset the message is encoded in. Failing that, will use Encode::Guess to try to figure it out
-When handed a MIME::Entity will first attempt to read what charset the message is encoded in. Failing that,
-will use Encode::Guess to try to figure it out
+If $head_only is true, only guesses charset for head parts. This is because header's encoding (e.g. filename="...") may be different from that of body's.
=cut
sub _FindOrGuessCharset {
my $entity = shift;
=cut
sub _FindOrGuessCharset {
my $entity = shift;
+ my $head_only = shift;
my $head = $entity->head;
if ($head->mime_attr("content-type.charset")) {
return $head->mime_attr("content-type.charset");
}
my $head = $entity->head;
if ($head->mime_attr("content-type.charset")) {
return $head->mime_attr("content-type.charset");
}
- if ( $head->mime_type =~ m{^text/}) {
+ if ( !$head_only and $head->mime_type =~ m{^text/}) {