Email character set conversion in procmail

Todd Zullinger tmz at pobox.com
Mon May 22 21:51:05 UTC 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Paul Howarth wrote:
> Does anyone have a procmail recipe for email character set
> conversion? I help to run an email newsletter, where people send in
> contributions that get edited together into a single message that is
> then sent out to all the list members. It would be nice if all of
> the incoming messages were in the same character set (e.g. utf8,
> iso-8859-1, whatever) from the point of view of pasting them into a
> single document, but I haven't been able to find a recipe for doing
> this automatically. Any suggestions?

Something piping the mail through iconv or recode is what I'd think
you want.  Here's one I found via google and tweaked a little:

# convert utf to latin (if the subject is translate me)
:0
* ^Subject: translate me$
* ^Content-Type: text/(plain|html); .*charset=.?utf-8
{
    :0 fbw
        |iconv -f UTF-8 -t ISO-8859-1//TRANSLIT

    :0 fhw
        * ^Content-Type: text/plain
        |formail -c -i "Content-Type: text/plain; charset=ISO-8859-1"

    :0 Efhw
        * ^Content-Type: text/html
        |formail -c -i "Content-Type: text/html; charset=ISO-8859-1"
}

Maybe that'll get you started on a good solution.  Or maybe it will
inspire someone that knows much better than I to post a better
solution. :)

It's probably better to go in the other direction, from latin to utf,
as there are bound to be characters in utf that can't get converted to
latin.  But I'm not a charset guru so it's all guesswork for me.

- -- 
Todd        OpenPGP -> KeyID: 0xD654075A | URL: www.pobox.com/~tmz/pgp
======================================================================
Everyone needs to believe in something. I believe I'll have another
beer.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: When crypto is outlawed bayl bhgynjf jvyy unir cevinpl.

iG0EARECAC0FAkRyMkkmGGh0dHA6Ly93d3cucG9ib3guY29tL350bXovcGdwL3Rt
ei5hc2MACgkQuv+09NZUB1opxwCglObJnURvoZ7wuXRlwyMCQF+cpgAAoKiNCZeX
7Yhx5W142q6XaW9NEzPM
=nVlZ
-----END PGP SIGNATURE-----




More information about the fedora-list mailing list