nemesis's Journal

Hilfe! German emails in mutt?

Monday 28th February, 2011

I've started getting a lot of emails in German lately, but Mutt hasn't been displaying them properly. For non-us-ascii characters (e.g. ß), it'd either show \223, or a '?'. This was really beginning to bug me.

Here's the problem: As far as I can tell, most German websites that fire off emails "assume" an encoding of cp1252, the old Windows encoding (correct me if I'm wrong!). Mutt on the other hand, if the encoding's not specified, assumes us-ascii, which doesn't contain these "special" characters (for us English speakers). The problem is further compounded by using a terminal or locale that may not have these characters, too.

Here's how to fix it.

First, you need to use a locale and a terminal that can display these characters. I'm using UTF-8. To check, type "locales". You should see, at minimum:

LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"

If you're not using UTF-8, you can change your locale on Debian with `dpkg-reconfigure locales`. If you get "command not found", then `aptitude install locales` first.

Second, check your terminal emulator (i.e., ssh client) supports the special characters. Easy check: Copy and paste this "ß" into your terminal.

Third, tell Mutt you want to use UTF-8, and to assume any messages that don't specifically mention an encoding are cp1252. Add this to the top of your .muttrc:

set charset=utf-8
charset-hook ^us-ascii$ cp1252
set assumed_charset="cp1252"

And finally, to make HTML emails decode properly, in /etc/mailcap, replace any instance of

text/html; /usr/bin/w3m -dump -T text/html

with

text/html; /usr/bin/w3m -dump -I %{charset} -T text/html

Enjoy!

0 Responses

Leave a comment

Sign in to leave a comment!

Don't have a login yet? Get one now!