MySQLi connection character set problem

From: Date: Tue, 11 Jan 2005 02:10:31 +0000
Subject: MySQLi connection character set problem
Groups: php.db 
Request: Send a blank email to php-db+get-38094@lists.php.net to get a copy of this message
Greetings! How can I set the connection character encoding that will be used by mysqli to talk to a MySQL 4.1.8 database (from PHP 5.0.3) ? I want to use UTF-8 all the way. The data that PHP sends to the database is in UTF-8 already and all my tables are using UTF-8 as well. The only problem is that the connection character set (as reported by mysqli_character_set_name) always defaults to latin1_swedish_ci (which I believe is the default for latin1). There must be a way to tell mysqli to use UTF-8 for the connection, right ? I've currently falled back to using the following (which seems like a big waste): // The content is encoded in this charset when it leaves the client $sql_result = mysqli_query($db_link, "SET NAMES 'latin1'"); // The content should be translated to this charset when it arrives at the mysql server $sql_result = mysqli_query($db_link, "SET CHARACTER SET 'utf8'"); I also tried setting defaults in /etc/my.cnf but mysqli (or libmysql) doesn't seem to be reading those. Any ideas would be greatly appreciated. TIA Jean-Philippe

« previous php.db (#38094) next »