mailcap on Windows WSL

Jan Eden tech at eden.one
Tue Oct 8 06:55:38 UTC 2024


Good morning,

I need to use mutt within the WSL of MS Windows. To display HTML
mails via mailcap, I created a small script which reads from STDIN,
writes a temporary file and opens it with the Edge browser:

# ~/.mutt/mailcap
text/html; ~/.mutt/htmlviewer html

# ~/.mutt/htmlviewer
with open('/var/tmp/htmlfile', 'w') as tmp_file:
	for line in sys.stdin:
		tmp_file.write(line)

This works for some messages, but for others, a UnicodeEncodeError is
returned:

'utf-8' can't encode character '...' in position ...: surrogates not
allowed

Since all of the messages affected were encoded in iso-8859-1, I tried
this (temporarily, with the intention of reading %{charset} from mutt
into the script later):

with open('/var/tmp/htmlfile', 'w', encoding='iso-8859-1') as tmp_file:
	...

but this only changed the error message to:

'latin-1' can't encode character '...' in position ...: ordinal not in
range(256)

How can I reliably write the input provided by mutt to a temporary file?

- Jan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.mutt.org/pipermail/mutt-users/attachments/20241008/b51f79bf/attachment.asc>


More information about the Mutt-users mailing list