Req #33604 [Asn->Dup]: MYSQL: php.ini option to set character_set and allow using UTF8

From: Date: Mon, 31 Jan 2011 10:47:49 +0000
Subject: Req #33604 [Asn->Dup]: MYSQL: php.ini option to set character_set and allow using UTF8
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-158355@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=33604&edit=1 ID: 33604 Updated by: johannes@php.net Reported by: dlacroix at erasme dot org Summary: MYSQL: php.ini option to set character_set and allow using UTF8 -Status: Assigned +Status: Duplicate Type: Feature/Change Request Package: MySQL related PHP Version: 5.0.4 Assigned To: mysql Block user comment: N Private report: N New Comment: Duplicate, as ulf said. Previous Comments: ------------------------------------------------------------------------ [2011-01-06 17:12:00] uw@php.net Duplicate of http://bugs.php.net/bug.php?id=44118 ------------------------------------------------------------------------ [2010-07-25 02:02:41] mabi at gentoo dot org Just attached the patch gentoo currently ships for this. In short: it provides a mysql.connect_charset php.ini option and uses mysql_options so that each connection will have this charset set by default. We use a similar patch for mysqli. The patch is not mine (I just adapted it to work with php-5.3.3), the original credits are: Initial patch by Stuart (?) and CHTEKK Updated for 5.3 by hoffie ------------------------------------------------------------------------ [2005-07-07 15:43:00] dlacroix at erasme dot org Description: ------------ There is no option in php.ini to setup the character set used with the MySQL connection. I'm using PHP in UTF-8 per default, MySQL 4.1.11 in UTF-8 but when I open a connection with PHP-MySQL it use latin1. I need an option to set the character set to UTF-8 when a connection is opened like in my.cnf file for mysql client. I have written a patch for php-mysql-5.0.4. It add mysql.default_character_set variable. Like that you can set: mysql.default_character_set = utf8 I still have a problem with mysql_client_encoding function that return latin1 even if the database is well using UTF-8. But it seems to be a MySQL client problem. Without this patch PHP program like SPIP are missusing the database and thing can be double encoded in UTF-8. This patch just add the following MySQL command when a connection is opened: SET character_set_client=choosed value SET character_set_connection=choosed value SET character_set_results=choosed value Reproduce code: --------------- Patch is available here: http://index.erasme.org/php-5.0.4-mysql-characterset.patch else you can ask me (dlacroix@erasme.org) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=33604&edit=1

« previous php.bugs (#158355) next »