[b][color=darkblue]1. mysql_client_encoding()是干什么的?他存在哪些问题?[/color][/b]
手册上说mysql_client_encoding [quote]Returns the default character set name for the current connection.[/quote]
[b][color=darkblue]2. 他到底是返回character_set_server, character_set_system 系统变量的值,还是character_set_connect或character_set_client系统变量的值呢?[/color][/b]
经过测试,以上全部是,不知道他返回的是哪个值。
[color=darkblue][b]
3. 怎样修改他的返回值?[/b][/color]
[url]http://cn.php.net/manual/en/function.mysql-client-encoding.php[/url]上讨论得如火如荼,但是问题仍然没有解决:
[quote]even if all your HTML/php source files are stored as 'utf-8' with header
<mata http-equiv="Content-type" content="type: text/html; charset=utf-8" />
and mysql server is everywhere UTF-8, adding 'set names "utf8"' and 'set character set "utf-8"' into your php to mysql connection,
you will always get the 'latin1' result by mysql_client_encoding();[/quote]
如果你的php版本>= 5.2.3,会有这么一个函数,mysql_set_charset()它可以改变mysql_client_encoding的返回值。但这只是形式上的,实际上你不需要顾问这个返回值,只要
[color=darkblue]
[b]4. set names 'charset' 和 set character set 'charset'有什么区别?[/b][/color]
有一点区别,不过大多数情况下一样。
set names 'x'等价于:
而set character set 'x'等价于:
手册上说mysql_client_encoding [quote]Returns the default character set name for the current connection.[/quote]
[b][color=darkblue]2. 他到底是返回character_set_server, character_set_system 系统变量的值,还是character_set_connect或character_set_client系统变量的值呢?[/color][/b]
经过测试,以上全部是,不知道他返回的是哪个值。
[color=darkblue][b]
3. 怎样修改他的返回值?[/b][/color]
[url]http://cn.php.net/manual/en/function.mysql-client-encoding.php[/url]上讨论得如火如荼,但是问题仍然没有解决:
[quote]even if all your HTML/php source files are stored as 'utf-8' with header
<mata http-equiv="Content-type" content="type: text/html; charset=utf-8" />
and mysql server is everywhere UTF-8, adding 'set names "utf8"' and 'set character set "utf-8"' into your php to mysql connection,
you will always get the 'latin1' result by mysql_client_encoding();[/quote]
如果你的php版本>= 5.2.3,会有这么一个函数,mysql_set_charset()它可以改变mysql_client_encoding的返回值。但这只是形式上的,实际上你不需要顾问这个返回值,只要
set names '你想要的字符集'
就可以了
[color=darkblue]
[b]4. set names 'charset' 和 set character set 'charset'有什么区别?[/b][/color]
有一点区别,不过大多数情况下一样。
set names 'x'等价于:
SET character_set_client = 'x';
SET character_set_results = 'x';
SET character_set_connection = 'x';
而set character set 'x'等价于:
SET character_set_client = 'x';
SET character_set_results = 'x';
SET collation_connection = @@collation_database;