[PATCH] parsemail: Fallback to common charsets when charset is None or x-unknown
siddhesh at redhat.com
Mon Jul 14 15:19:08 EST 2014
On Mon, Jul 14, 2014 at 10:21:32AM +0800, Jeremy Kerr wrote:
> if not isinstance(payload, unicode):
> - payload = unicode(payload, charset)
> + charset = part.get_content_charset()
> + # Check that we have a charset that we understand. Otherwise,
> + # ignore it and fallback to our standard set.
> + if charset is not None:
> + try:
> + codec = codecs.lookup(charset)
> + except LookupError:
> + charset = None
Thanks, that looks like a better idea to me too.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 473 bytes
Desc: not available
More information about the Patchwork