How to set the sjis environment for PHP5.1 and MySQL4.1
| From: | Kiyoshi Inoue | Date: | Sun, 09 Apr 2006 12:23:03 +0000 |
| Subject: | How to set the sjis environment for PHP5.1 and MySQL4.1 | ||
| Groups: | php.i18n | ||
| Request: | Send a blank email to php-i18n+get-995@lists.php.net to get a copy of this message | ||
It seems to me that PHP5.1.1 doesn't go well with MySQL 4.1.16
in handling 2 byte sjis coded japanese character.
SET NAMES 'sjis' command doesn't work in the following PHP script.
Before and afer this command, the current characer set remains the same as latin1-swedish, while server and databese character set are set to sjis.
I've been struggling in vain to resolve this mojibake problem.
$link = mysql_connect('localhost', 'sampuser', 'tbnq0206')
OR die(mysql_error());
$charset = mysql_client_encoding($link);
echo "The current character set is : $charset\n";
mysql_query("SET NAMES 'sjis'", $link);
$charset = mysql_client_encoding($link);
echo "The current character set is : $charset\n";
Cheers,
Kiyoshi Inoue