Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Viewing html mail with different charsets in mutt
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
bludger
Guru
Guru


Joined: 09 Apr 2003
Posts: 389

PostPosted: Fri May 25, 2007 3:53 pm    Post subject: Viewing html mail with different charsets in mutt Reply with quote

I thought that I would share with you the method that I recently discovered of getting mutt to show html mails with various charsets.

~/.muttrc:
Code:
auto_view text/html


/etc/mailcap:
Code:
text/html; /usr/bin/lynx -dump -assume_charset=%{charset} -display_charset='utf8'  -force_html '%s'; copiousoutput; description=HTML Text; nametemplate=%s.html

(Assuming your system uses utf8. If not use another setting for -display_charset)

I have tested this with various combinations of mails sent with various charsets and characters, eg ascii only, iso-8859-1 (used when the mail has umlauts etc) and utf8 (used when the mail includes a Euro Symbol €). It displays most of these correctly.

All that is left is getting lynx to display the text formatting. Any ideas? I tried switching to elinks, but it doesn't seem to have an equivalent to the assume_charset parameter and so cannot interpret some charsets correctly.
Back to top
View user's profile Send private message
ag_x
Tux's lil' helper
Tux's lil' helper


Joined: 11 Jun 2004
Posts: 142
Location: Self Sarkarm.

PostPosted: Sat May 26, 2007 4:34 pm    Post subject: Re: Viewing html mail with different charsets in mutt Reply with quote

bludger wrote:
I tried switching to elinks, but it doesn't seem to have an equivalent to the assume_charset parameter and so cannot interpret some charsets correctly.

You can use "-dump-charset utf8" with elinks for the same result.
Note:
However for this to work correctly, it needs a recent snapshot from the unstable branch 0.12, plus you have to enable the configuration option "--enable-utf-8".
See bug #822 in the elinks bugzilla.

So assuming you've done that, you can then use something like:
Code:

text/html; elinks -dump -dump-charset utf8 -force-html %s; copiousoutput; needsterminal; nametemplate=%s.html

There are a bunch of "dump*" options in elinks; for reference you can have a look in `man elinks.conf'.
For example, you can disable numbered links in the dump format, with "-no-numbering".

Another option is to use Vilistextum [1] with "-u" option to output in UTF-8.

1. http://bhaak.dyndns.org/vilistextum/
Back to top
View user's profile Send private message
bludger
Guru
Guru


Joined: 09 Apr 2003
Posts: 389

PostPosted: Mon May 28, 2007 2:36 pm    Post subject: Reply with quote

-dump-charset in elinks seems to be the equivalent of display_charset (or the output charset) in lynx and not assume_charset, which is the input charset. Some mails are sent as ascii, some as iso8559-1 and some as utf8 and the program needs to recognise this.
Back to top
View user's profile Send private message
ag_x
Tux's lil' helper
Tux's lil' helper


Joined: 11 Jun 2004
Posts: 142
Location: Self Sarkarm.

PostPosted: Wed May 30, 2007 5:32 pm    Post subject: Reply with quote

bludger wrote:
-dump-charset in elinks seems to be the equivalent of display_charset (or the output charset) in lynx and not assume_charset, which is the input charset. Some mails are sent as ascii, some as iso8559-1 and some as utf8 and the program needs to recognise this.

Oh yes, you are absolutely right, I didn't realize the difference.

I am not taking a lot of html documents (some from my ISP, and some from some official organizations I am working with), and the most of them have the proper HTTP header like: charset=iso-8859-7
so elinks doesn't gave me any problems so far.

To be honest and confess my stupidity, I still can not understand (how it works), this part of the mailcap entry.
-assume_charset=%{charset}
Not that I have lynx anymore installed, just curiosity.
Back to top
View user's profile Send private message
bludger
Guru
Guru


Joined: 09 Apr 2003
Posts: 389

PostPosted: Thu May 31, 2007 3:01 pm    Post subject: Reply with quote

It basically works like this. Some mail clients send html with the charset specified in the mime type header of the email and not in the html itself. If you just deliver this html to lynx, it has no way of knowing which charset to use. Thus German umlauts etc. will not be displayable.

You can use the -assume_charset field to deliver the correct charset (from the mime type in the email header) to lynx.

As a test, I sent a normal text mail from outlook to my linux mail server.

The mail header contained an attachment with the following mime type:
Content-Type: text/html;
charset="us-ascii"
In mutt this was viewed with:
Autoview using /usr/bin/lynx -dump -assume_charset='us-ascii' -display_charset='utf8' -force_html ''/tmp/mutt.html''


Another mail containing an umlaut was sent from outlook. This contained the following mime type in the mail header:
Content-Type: text/html; charset=ISO-8859-1
In mutt this was viewed with:
Autoview using /usr/bin/lynx -dump -assume_charset='ISO-8859-1' -display_charset='utf8' -force_html ''/tmp/mutt.html''

I tested a utf8 html attachment by posting a mail with a Euro symbol.
Back to top
View user's profile Send private message
ag_x
Tux's lil' helper
Tux's lil' helper


Joined: 11 Jun 2004
Posts: 142
Location: Self Sarkarm.

PostPosted: Fri Jun 01, 2007 7:31 am    Post subject: Reply with quote

bludger wrote:
You can use the -assume_charset field to deliver the correct charset (from the mime type in the email header) to lynx.

Oh, that was my first thought too, but I wasn't quite sure, so thanks for the details, I appreciate it.

I made some experiment too, including removing manually (within mutt) the relative headers and I still could
display the non ascii characters, using elinks with the same way I posted above.

I don't know the way it uses to determine the charset but it looks that is quite effective.
Have you used a recent snapshot from the development branch?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum