Characters aren't displayed correctly

Hussein B hubaghdadi at gmail.com
Mon Mar 2 03:30:53 EST 2009


On Mar 1, 4:51 pm, Philip Semanchuk <phi... at semanchuk.com> 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?
Yes they are.

> Are they stored consistently (i.e. all using the same encoding, not  
> some using utf-8 and others using iso-8859-1)?
Yes.

> What are you getting out of the database? Is it being converted to  
> Unicode correctly, or at all?
I don't know, how to make sure of this point?

> Are you sure that the program you're using to view the email  
> understands the encoding?
Yes.

> 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




More information about the Python-list mailing list