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
signature.asc
Description: PGP signature
