I am troubled by coding problems (leading to Chinese garbled characters!

Source: Internet
Author: User
Encoding problems that plague me (leading to Chinese garbled characters !!! My website pages are all encoded in gb2312 format (cannot be changed). I can change the mysql database! Can I change the data in mysql database from utf8_general_ci to gb2312_chinese_ci to solve the problem from the root? Utf8_general: the encoding problem that plagued me (leading to Chinese garbled characters !!!
My website pages are all encoded in gb2312 format (cannot be changed). I can change the mysql database!
Can I change the data in mysql database from utf8_general_ci to gb2312_chinese_ci to solve the problem from the root?
What are the essential differences between utf8_general_ci and gb2312_chinese_ci, such as storage capacity and read speed? Share:
------ Solution --------------------
I have watched the php video of Chuanzhi podcast. it seems that I have heard that the utf8 Chinese character is three bytes, while the gb2312 Chinese character is two bytes.
------ Solution --------------------
Encoding during mysql connection should also be set
------ Solution --------------------
That means your database is utf8_general_ci.
No modification required!
You only need to execute set names gbk after each database connection.

There is no essential difference between utf8_general_ci and gb2312_chinese_ci, but the former and the latter occupy 3: 2



------ Solution --------------------
The page you mentioned cannot be changed. the package does not contain php code. if you add mysql_query ("set names utf8") in php, it will be troublesome.
------ Solution --------------------
Yes, set name encoding is required for your page (UTF-8 is required for utf8 writing)
When the data is sent to ajax, run
Header ('content-type: text/html; charset = gbk ');
You can.
------ Solution --------------------
I changed the database settings. Should I rewrite the original data?

Unicode UTF-8 characters in the range of 0800-ffff are three bytes. common Chinese, Japanese, Korean, Mongolian, and Tibetan characters are in this range.

There are a small number of uncommon Chinese characters, North Korean characters are 010000 out of the box, and the corresponding UTF-8 is more bytes, but these characters are mostly ancient characters, not common, and generally cannot be displayed in the font of windows, they can be ignored.

GBK-encoded Chinese characters and symbols are dubyte
------ Solution --------------------
Gbk_chinese_ci instead of gb2312_chinese_ci
The former has more than 20 thousand Chinese characters, and the latter has more than six thousand Chinese characters.

The numbers of Chinese characters in gbk_chinese_ci and utf8_general_ci are the same.
However, the latter accounts for 50% of the storage space.

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.