Thank you all for the helpful comments.
I've finally solved the problem through sql command "set name."
On 1/22/2010 1:53 AM, Michael A. Peters wrote:
Ashley Sheridan wrote:
You're also forgetting one of the most important elements of this. If
you're displaying the characters on a web page, chances are that you
need to add a corresponding meta tag to inform the browser that the
content is utf-8
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
Otherwise the browser will attempt to guess from the first few
characters of output, and because of the large headers in some websites,
will guess completely wrong.
Just to add - I had to deal with this, I think I got it right now but
I'm not positive.
My /etc/my.cnf file has the following:
default-character-set=utf8
That way I don't have to remember to specify the charset when I create
a new table.
If you don't have control over that file (IE shared host) when you
create your database tables, I believe you need to do
SET character_set_client = utf8;
before your create table commands.
You should also send the charset in a header, IE
header('Content-type: text/html; charset=utf-8');
but for html you also need to have the meta tag as mentioned because
if the page is saved to disk, there's no other way for a browser to
know the charset (and if it isn't there, w3c validator complains).
proper xhtml doesn't need the meta tag because it has the charset in the
<?xml version="1.0" encoding="UTF-8"?>
that opens a proper xhtml document.
If the charset isn't set, then any information sent via post will
probably be sent using whatever charset the operating system uses by
default, so setting the charset to utf-8 is important for pages that
are forms as well as pages that display data.
I'm by no means an expert, that's just what I had to do to get
Aneides iëcanus
to properly display.
I already was doing the utf-8 for the web pages, but MySQL defaults to
a different character set - I consider it a CentOS bug, they should
have shipped with my.cnf set to utf-8 IMHO because just about
everything else in the OS is utf-8 by default, but I pulled my hair
out for half an hour trying to figure out why it wasn't working when
the reason was the default charset of the MySQL client used to
initially create the database table.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php