Use MySQL and PHP to appear Chinese garbled solution

Source: Internet
Author: User
Tags character set

Gb2312,gbk,utf8, such as the support of multibyte-encoded character sets can store Chinese characters, gb2312 in the number of Chinese characters is far less than GBK, and GB2312,GBK can be encoded in the UTF8.

Two. Show variables like ' character\_set\_% ' by command; View current character Set settings:

mysql> show variables like 'character\_set\_%';
+--------------------------+--------+
| Variable_name      | Value |
+--------------------------+--------+
| character_set_client   | gb2312 |
| character_set_connection | gb2312 |
| character_set_database  | gb2312 |
| character_set_filesystem | binary |
| character_set_results  | gb2312 |
| character_set_server   | latin1 |
| character_set_system   | utf8  |
+--------------------------+--------+
7 rows in set (0.02 sec)

(The character set here is gb2312)

Display Chinese garbled mainly has two settings: Character_set_connection and Character_set_results,

If your two settings do not support Chinese encoding, there will be garbled, as long as: Set Character_set_results =GBK, set the Chinese code.

Three. Set names Charset_name; You can set all character sets for the client at once.

Related Article

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.