Characters aren't displayed correctly

John Machin sjmachin at lexicon.net
Mon Mar 2 09:31:34 EST 2009


On Mar 2, 7:30 pm, Hussein B <hubaghd... at gmail.com> wrote:
> 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.

Can you reveal which language???

> > > 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.

How do you KNOW that they are stored correctly? What makes you so
sure?

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

So what is the encoding used to store them?

>
> > 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?

You could show us some of the output from the database query. As well
as
   print the_output
you should
   print repr(the_output)
and show us both, and also tell us what you *expect* to see.

And let's get the database output sorted out before we worry about the
email message.



More information about the Python-list mailing list