Marko Lalic added the comment:
Thank you for your reply.
Unfortunately, I have a use case where message_from_bytes has a pretty great
disadvantage. I have to parse the received message and then forward it
completely unchanged, apart from possibly adding a few new headers. The problem
with
Marko Lalic added the comment:
That will work fine as long as the characters are actually latin. We cannot
forget the rest of the unicode character planes. Consider::
>>> message = message_from_string("""MIME-Version: 1.0
... Content-Type: text/plain; charset=utf-8
New submission from Marko Lalic:
When the message's Content-Transfer-Encoding is set to 8bit, the
get_payload(decode=True) method returns the payload encoded using
raw-unicode-escape. This means that it is impossible to decode the returned
bytes using the content charset obtained b