I think it is the best solution I've found until now...

see #410
This commit is contained in:
Antoine Nguyen
2013-04-26 15:47:19 +02:00
parent 24c84acf6a
commit 27b0034211
+7 -2
View File
@@ -53,14 +53,19 @@ class IMAPheader(object):
def to_unicode(value):
if value is None or type(value) is unicode:
return value
try:
value = value.decode('utf-8')
except UnicodeDecodeError:
pass
else:
return value
try:
res = chardet.detect(value)
except UnicodeDecodeError:
return value
if res["encoding"] == "ascii":
return value
return value
#return value.decode(res["encoding"])
return value.decode(res["encoding"])
@staticmethod
def parse_address(value, **kwargs):