From: Kjetil Torgrim Homme <kjetilho@haey.ifi.uio.no>
Subject: Re: mime QP and B headers in body
Date: 13 Jan 2003 08:32:52 +0100 [thread overview]
Message-ID: <1rel7hjyhn.fsf@glesvat.ifi.uio.no> (raw)
In-Reply-To: <87wulax72k.fsf@jidanni.org>
[Dan Jacobson]:
>
> > I make a daily spam report
> > * Subject: =?BIG5?B?ttmhS...
> > * Subject:=?big5?Q?=A7A=B...
> > * Subject: Want a BIG Pen...
> > * Subject: =?GB2312?B?1tC...
> > * Subject: =?ISO-8859-1?B...
>
> If you normalized all the charsets to, say, iso-2022-* or utf-8, that
> would probably make it easier to read.
>
> i could make a big program to make them all utf-8 which would
> involve a lot of sed and awk and iconv which is very picky and i
> dare not complain about lest i have another encounter with drepper
please quote properly!
it's not that hard to do:
#! /usr/bin/perl -w
use MIME::Base64;
use MIME::QuotedPrint;
sub recode {
my ($charset) = shift;
my $tmp = "/tmp/reco.$$";
open (TMP, ">$tmp") || die;
print TMP @_;
close (TMP);
my $ans = "";
print "recode $charset..UTF8 < $tmp\n";
open (RECODE, "recode <$tmp $charset..UTF8|") || die;
while (<RECODE>) {
$ans .= $_;
}
unlink ($tmp);
$ans;
}
while (<>) {
if (/=\?(\S+?)\?B\?(\S+)\?=/i) {
my ($charset, $word) = ($1, $2);
print recode ($charset, decode_base64 ($word)), "\n";
} elsif (/=\?(\S+?)\?Q\?(\S+)\?=/i) {
my ($charset, $word) = ($1, $2);
$word =~ tr/_/ /;
print recode ($charset, decode_qp ($word)), "\n";
} else {
print;
}
}
oh, duh, this only decodes the first quoted-word on each line.
consider it an exercise for the reader.
--
Kjetil T. | read and make up your own mind
| http://www.cactus48.com/truth.html
next parent reply other threads:[~2003-01-13 7:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87wulax72k.fsf@jidanni.org>
2003-01-13 7:32 ` Kjetil Torgrim Homme [this message]
[not found] <871y3i7pcj.fsf@jidanni.org>
2003-01-12 11:26 ` Lars Magne Ingebrigtsen
2003-01-15 8:18 ` Dan Jacobson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1rel7hjyhn.fsf@glesvat.ifi.uio.no \
--to=kjetilho@haey.ifi.uio.no \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).