[Erp5-report] r21105 - /erp5/trunk/products/ERP5/Document/EmailDocument.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri May 23 18:17:57 CEST 2008


Author: nicolas
Date: Fri May 23 18:17:57 2008
New Revision: 21105

URL: http://svn.erp5.org?rev=21105&view=rev
Log:
Convert Text Content into utf-8

Modified:
    erp5/trunk/products/ERP5/Document/EmailDocument.py

Modified: erp5/trunk/products/ERP5/Document/EmailDocument.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/EmailDocument.py?rev=21105&r1=21104&r2=21105&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/EmailDocument.py (original)
+++ erp5/trunk/products/ERP5/Document/EmailDocument.py Fri May 23 18:17:57 2008
@@ -264,8 +264,15 @@
     html_result = None
     for part in self._getMessage().walk():
       if part.get_content_type() == 'text/plain' and not text_result and not part.is_multipart():
-        text_result = part.get_payload(decode=1)
+        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)
       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 text_result
 




More information about the Erp5-report mailing list