On Thu, 2008-12-11 at 19:02 -0800, I.A wrote:
> Hi,
> 
> I'm wondering the correct way to save unicode data in MySQL through
> django's models.
> The application I'm building reads a raw email and then stores the
> text data into the database. I process the email like so:
> 
> import email
> mess822 = email.message_from_string(email_raw_data)
> mail_unicode_data = unicode(mess822.get_payload(),
> mess822.get_content_charset('utf-8'))
> 
> Nearly all of the email that I get are from Japanese clients emails,
> mess822.get_content_charset() will usually return 'iso-2022-jp'

[...]


> After getting the payload data from the email, I do
> 
> ce = ClientsEmail(mail_text = mail_unicode_data)
> ce.save()

This is fine. Passing unicode objects to Django will always work.
Converting it back to a UTF-8 encoded bytestring (a Python "str") is
unnecessary.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to