[PATCH] parsemail: Fallback to common charsets when charset is None or x-unknown
Siddhesh Poyarekar
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.
Thanks,
Siddhesh
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/patchwork/attachments/20140714/8cdb2c02/attachment.sig>
More information about the Patchwork
mailing list