X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=docs%2Fcontrib%2Freplyfilter;h=b74465a9f854ad86d3a238f70f3394c66f56d003;hb=02e25280094d8245772acf03396fe31c278ea337;hp=193dd40b046efc8a14cff09d91e54671c5dce6dd;hpb=0cb3c82ac7c780c1588c495a36d725c1ca2a5c76;p=mmh diff --git a/docs/contrib/replyfilter b/docs/contrib/replyfilter index 193dd40..b74465a 100755 --- a/docs/contrib/replyfilter +++ b/docs/contrib/replyfilter @@ -160,6 +160,11 @@ sub process_text (*$$;$) # if ($encoding eq '7bit' || $encoding eq '8bit') { + # + # Switch the character set to whatever is specified by + # the MIME message + # + binmode($input, ":encoding($charset)"); while (<$input>) { $ret = match_boundary($_, $boundary); if (defined $ret) { @@ -169,6 +174,13 @@ sub process_text (*$$;$) } return 'EOF'; } else { + # + # If we've got some other encoding, the input text is almost + # certainly US-ASCII + # + + binmode($input, ":encoding(us-ascii)"); + $decoder = find_decoder($encoding); if (! defined $decoder) { return 'EOF'; @@ -180,12 +192,14 @@ sub process_text (*$$;$) # to filter it. Read it in; if it's too long, filter it. # + my $chardecode = find_encoding($charset); + while (<$input>) { my $line, $len; last if ($ret = match_boundary($_, $boundary)); - $line = decode($charset, &$decoder($_)); + $line = $chardecode->decode(&$decoder($_)); if (substr($text[$#text], -1, 1) eq "\n") { push @text, $line;