Re: mailcap on Windows WSL

José María Mateos <[email protected]>
Newsgroups gmane.mail.mutt.user
Message-ID <[email protected]>
On Tue, Oct 8, 2024, at 08:55, Jan Eden via Mutt-users wrote:
> 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)

You can tell open() how to handle errors with the 'errors' keyword. See https://docs.python.org/3/library/functions.html#open:

---
errors is an optional string that specifies how encoding and decoding errors are to be handled—this cannot be used in binary mode. A variety of standard error handlers are available (listed under Error Handlers), though any error handling name that has been registered with codecs.register_error() is also valid. The standard names include:

    'strict' to raise a ValueError exception if there is an encoding error. The default value of None has the same effect.

    'ignore' ignores errors. Note that ignoring encoding errors can lead to data loss.

    'replace' causes a replacement marker (such as '?') to be inserted where there is malformed data.
---

You're not setting it, so it's the same as it being 'strict'. I'd try with 'replace', so you can see characters that were replaced and were potentially problematic.

Cheers,

-- 
José María (Chema) Mateos || https://rinzewind.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.