Characters aren't displayed correctly
J. Clifford Dyer
jcd at sdf.lonestar.org
Sun Mar 1 16:27:08 EST 2009
On Sun, 2009-03-01 at 09:51 -0500, Philip Semanchuk wrote:
> On Mar 1, 2009, at 8:31 AM, Hussein B wrote:
>
> > Hey,
> > I'm retrieving records from MySQL database that contains non english
> > characters.
> > Then I create a String that contains HTML markup and column values
> > from the previous result set.
> > +++++
> > markup = u'''<table>.....'''
> > for row in rows:
> > markup = markup + '<tr><td>' + row['id']
> > markup = markup + '</table>
> > +++++
> > Then I'm sending the email according to this tip:
> > http://code.activestate.com/recipes/473810/
> > Well, the email contains ????? characters for each non english ones.
> > Any ideas?
>
> There's so many places where this could go wrong and you haven't
> narrowed down the problem.
>
> Are the characters stored in the database correctly?
>
> Are they stored consistently (i.e. all using the same encoding, not
> some using utf-8 and others using iso-8859-1)?
>
> What are you getting out of the database? Is it being converted to
> Unicode correctly, or at all?
>
> Are you sure that the program you're using to view the email
> understands the encoding?
>
> Isolate those questions one at a time. Add some debugging breakpoints.
> Ensure that you have what you think you have. You might not fix your
> problem, but you will make it much smaller and more specific.
>
>
> Good luck
> Philip
>
>
Let me add to that checklist:
Are you sure the email you are creating has the encoding declared
properly in the headers?
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
Cheers,
Cliff
More information about the Python-list
mailing list