Once again I have a weird and tricky problem.
I've been working with converting my MySQL databases (and everything else on my server for that matter) to UTF-8 to avoid having to convert text when getting and putting text into the different databases.
I think I've partially succeeded because SHOW VARIABLES LIKE 'character_set%'
returns:
character_set_client utf8
character_set_connection utf8
character_set_database utf8
character_set_filesystem binary
character_set_results utf8
character_set_server utf8
character_set_system utf8
But still mysql_client_encoding($con);
returns latin1
and in the output every special character is replaced with �. My conclusion is that the client or the connection between PHP and the MySQL database is using latin1 even though I've been specifying utf-8 in the document header and in my.ini with the following code:
character-set-server = utf8
character-set-client = utf8
default-character-set = utf8
edit: I've added the settings above under both [client], [mysqld] and [mysql]
When I use mysql_query('SET NAMES utf8;');
or mysql_set_charset("utf8");
the text shows properly but for me that's not a sollution, just a temporary fix.
Does anyone know how to force PHP (or whatever it is reverting to latin1) to use utf-8?
I should mention that I'm using Windows 2003 Server and Apache 2.
mysql_xxx()
functions are considered obsolete and should no longer be used. The PHP manual recommends using either the equivalentmysqli_xx()
functions or the PDO library instead. – Advection