PHP,AJAX,MYSQL,LATIN1 Encoding related issues

Source: Internet
Author: User
Php,ajax,mysql,latin1 Coding Problems
MySQL default latin1 encoding, read the data with Ajax read garbled, in the server side of the ajax.php, there are two places involved in the code:

A.header (' Content-type:text/xml;charset=utf-8 ');
B. When querying, add mysql_query ("Set names ' UTF8 '");

In addition, the ajax.php itself is utf-8 encoded.

Can query the record, but look at the XML source code, but this is the content:
²èµêxóõý½öåé³öëù

Tried a lot of code conversion, have failed, please help me!!!!!

------Solution--------------------
XML plus UTF8 coding try
------Solution--------------------
MySQL default latin1 encoding change Utf-8
Client HTML with Utf-8
To the time, whether it is shrimp-like, as long as the client can normally display on OK
------Solution--------------------
Multibyte characters do not use LATIN1. Suggest using UTF8 or GBK
------Solution--------------------
Best Unified encoding Format ~ ~
------Solution--------------------
With Iconv () Unified Code No?
------Solution--------------------
B. When querying, add mysql_query ("Set names ' UTF8 '");

It should be mysql_query ("Set names ' UTF-8 '");

The ajax.php output XML is Iconv () to the code.

$xml = "XML data coming out";

Echo iconv ("Latin1", "Utf-8", $xml);
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.