Home >Backend Development >PHP Tutorial >Mysql取出来的中文是5位utf编码怎么处理

Mysql取出来的中文是5位utf编码怎么处理

WBOY
WBOYOriginal
2016-06-13 11:09:42950browse

Mysql取出来的中文是5位utf编码怎么办?
用php取mysql的值,在网页里看是,中文是5位utf8的编码,不是中文字.
请问是怎么回事?

mysql运行show variables like '%char%';结果如下
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

php这么写的
$conn = mysql_connect("localhost", "root", "1");
mysql_select_db("123", $conn);
mysql_query("set names 'utf8'");
$sql = "select * from 123.abc";
$result = mysql_query($sql);
$res1= mysql_fetch_array ( $result, MYSQL_NUM) ;
echo json_encode ( $res1 );
mysql_close($conn);
------解决方案--------------------
\u4e2d 这个形式吧?

这是 json_encode 处理的结果,不影响 php、js 使用
在 json_encode 之前依然是汉字

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn