MYSQL GB2312 data converted to UTF8 data

Source: Internet
Author: User
Tags phpmyadmin

First of all, the forum's managers and some of the forum on the sidelines of the people expressed regret.
Yesterday met GBK and UTF8 mutual turn problem, check a lot of data have not figured out, post questions nobody, to the management message is also heard.
Spent a few hours, looked up a lot of information (other forums), after the N-word failure finally converted to success, here to share to everyone, hope to provide help to the needy students.

Needless to say, the following are the necessary steps to convert, not necessarily suitable for everyone, so we hope that everyone before starting to backup good data. (Database and template materials)


GB2312 Turn UTF8:
First step: Open phpMyAdmin, export the Dedecms database (export>>save as file >>go)
The second step: Use Notepad to open the first step of the exported file, the GB2312 in which all replace the UTF8, and then save, save time encoding select Utf-8.
Step three: Install the UTF8 encoded DEDECMS program
Fourth step: Open phpMyAdmin to empty the data in the newly installed UTF8 version of the database (Structure>>select all>>go)
Fifth Step: Import, select the database file saved in the second step. (Import>>go)
So far, the data transformation and import succeeded.

///////////////////////////////

Souroot Note:

After the database has been converted to UTF-8, there are three things:

1) PHP to the database before all add Mysqli_query ($conn, "Set names UTF8"), so that in the transmission, the return of the results are used UTF-8 encoding;

If Mysqli_query ($conn, "Set names gb2312"), the background will be in the operation of the database, such as reading the database data, first to GB2312 to the client, or to get GB2312 data, the database is specifically encoded (this is UTF-8) , and then save to the database;

2) The UTF-8 code is indicated on the webpage.

<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>

3) for a PHP file with output HTML text, the file itself should be specifically for the UTF8 format encoding (preferably no BOM format, or PHP that the BOM format itself has been calculated output, this will affect the session start);

MYSQL GB2312 data converted to UTF8 data

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.