Commit b8a67dc0 authored by Nicolas Delaby's avatar Nicolas Delaby

Convert Text Content into utf-8

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21105 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e0802dfe
...@@ -264,8 +264,15 @@ class EmailDocument(File, TextDocument): ...@@ -264,8 +264,15 @@ class EmailDocument(File, TextDocument):
html_result = None html_result = None
for part in self._getMessage().walk(): for part in self._getMessage().walk():
if part.get_content_type() == 'text/plain' and not text_result and not part.is_multipart(): if part.get_content_type() == 'text/plain' and not text_result and not part.is_multipart():
part_encoding = part.get_content_charset()
if part_encoding != 'utf-8':
text_result = part.get_payload(decode=1).decode(part_encoding).encode('utf-8')
else:
text_result = part.get_payload(decode=1) text_result = part.get_payload(decode=1)
elif part.get_content_type() == 'text/html' and not html_result and not part.is_multipart(): elif part.get_content_type() == 'text/html' and not html_result and not part.is_multipart():
part_encoding = part.get_content_charset()
if part_encoding != 'utf-8':
return part.get_payload(decode=1).decode(part_encoding).encode('utf-8')
return part.get_payload(decode=1) return part.get_payload(decode=1)
return text_result return text_result
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment