procmail
[Top] [All Lists]

Re: Dekoding eight-bit characters in headers

1997-04-18 17:32:00
georg(_at_)ii(_dot_)uib(_dot_)no (Hans Georg Schaathun) writes:
I have set up procmail to decode QUOTED-PRINTABLE message bodies,
but if possible I would have the headers decoded, too...
I often get subject headers on this form:

: Subject: =?ISO-8859-1?Q?Referat_FU-m=F8te_14=2E03=2E97?=

Would anybody know if, and evt. how, this would be possible ?
Thanks a lot.

You'll need perl5.003 (or later, and possibly earlier if you're lucky),
and the perl libwww module (I'm not sure what version you would need) to
do this, but:


:0 fh
* =\?ISO-8859-[0-9]+\?Q\?
|perl -mMIME::QuotedPrint -pe 's:=\?ISO-8859-\d+\?Q\?(.*?)\?=:decode_qp($1):ge;'


If you don't have libwww, just perl5, then the following _should_ work:

:0 fh
* =\?ISO-8859-[0-9]+\?Q\?
|perl -pe 's#=\?ISO-8859-\d+\?Q\?(.*?)\?=#$s=$1; $s=~s/\s+(\r?\n)/$1/g; \
           $s=~s/=\r?\n//g; $s=~s/=([\da-fA-F]{2})/pack("C", hex($1))/ge; \
           $s#ge;'


BTW: your mail reader should really be doing this itself.  Beware that
some old MUAs *die* a horrible death on 8 bit characters in the header,
so be careful.

Philip Guenther

<Prev in Thread] Current Thread [Next in Thread>