Chris Green
2025-01-04 14:31:24 UTC
Reply
Permalinkworking OK (with various updates and improvements) for many years.
I now have a minor new problem when handling E-Mail with a From: that
has accented characters in it:-
From: Sébastien Crignon <***@amvs.fr>
I use Python mailbox to parse the message:-
import mailbox
...
...
msg = mailbox.MaildirMessage(sys.stdin.buffer.read())
Then various mailbox methods to get headers etc.
I use the following to get the From: address:-
str(msg.get('from', "unknown").lower()
The result has the part with the accented character wrapped as follows:-
From: =?utf-8?B?U8OpYmFzdGllbiBDcmlnbm9u?= <***@amvs.fr>
I know I have hit this issue before but I can't rememeber the fix. The
problem I have now is that searching the above doesn't work as
expected. Basically I just need to get rid of the ?utf-8? wrapped bit
altogether as I'm only interested in the 'real' address. How can I
easily remove the UTF8 section in a way that will work whether or not
it's there?
--
Chris Green
·
Chris Green
·