php,ajax,mysql,latin1编码有关问题

WBOY
Release: 2016-06-13 13:51:51
Original
963 people have browsed it

php,ajax,mysql,latin1编码问题
mysql默认latin1编码,用ajax读数据时读到乱码,在server端的ajax.php里,有这两个地方涉及到了编码:

a.header( 'Content-type:   text/xml;charset=utf-8 ');
b.查询时,加上了mysql_query( "set   names   'UTF8 ' ");

另外,ajax.php本身也是utf-8编码的。

能够查询出记录,但是查看XML源代码,却是这样的内容:
²èµê×ÓÕý½ÖÅɳöËù

尝试了很多种编码转换,都失败了,请各位达人帮帮我啦!!!!!

------解决方案--------------------
xml 也加上utf8编码试试
------解决方案--------------------
mysql默认latin1编码 改utf-8
客户端html用utf-8
传到的时候不管是虾米样的,只要在客户端能够正常显示就OK的啦
------解决方案--------------------
多字节字符不要用LATIN1。建议用UTF8或者GBK
------解决方案--------------------
最好统一编码格式~~
------解决方案--------------------
用iconv()统一编码不行吗;
------解决方案--------------------
b.查询时,加上了mysql_query( "set names 'UTF8 ' ");

应该是mysql_query( "set names 'UTF-8 ' ");吧.

ajax.php输出XML用iconv()转下码.

$xml = "即将输出的xml数据 ";

echo iconv( "latin1 ", "utf-8 ",$xml);

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!