handle unicode string (except for mimetype/filename)

This commit is contained in:
Mathieu Virbel 2012-03-12 19:14:39 +01:00
parent 290efe79e7
commit bc48d359e7

View file

@ -95,8 +95,12 @@ def send_email(subject, text, mimetype=None, filename=None, filename_alias=None,
cdef char *j_filename_alias = NULL
if subject is not None:
if type(subject) is unicode:
subject = subject.encode('UTF-8')
j_subject = <bytes>subject
if text is not None:
if type(text) is unicode:
text = text.encode('UTF-8')
j_text = <bytes>text
if mimetype is not None:
j_mimetype = <bytes>mimetype
@ -105,6 +109,8 @@ def send_email(subject, text, mimetype=None, filename=None, filename_alias=None,
if filename_alias is None:
filename_alias = basename(filename)
if type(filename_alias) is unicode:
filename_alias = filename_alias.encode('UTF-8')
j_filename_alias = <bytes>filename_alias