Current location - Quotes Website - Personality signature - How to solve the problem of GBK converting UTF-8 garbled code?
How to solve the problem of GBK converting UTF-8 garbled code?
I have been building websites with wordpress. Some time ago, I wanted to build an online question-and-answer platform with programs like dedecms. The template was installed and some simple tests were carried out, and some bugs were found, that is, the page asking questions appeared garbled, and it took a long time to know the reason. The reason is that the question page of this Q&A template uses gbk code, while the code of this system is utf8.

In fact, the reason is the same as the garbled WordPress theme in the last article, which is caused by the wrong format of saving coding. After finding the cause of the problem, the next step is to modify the encoding and convert the encoding of this webpage from gbk to utf8.

Originally, I wanted to find an online tool to convert gbk into utf8 and realize the conversion between gbk and utf8 formats online, but I couldn't find a satisfactory tool after searching for a long time, so I modified it with Dreamweaver, a powerful fckeditor. In fact, the operation is very simple, and the steps are as follows:

I. Template file conversion

(1) Open the template file with DW and select Modify-Page Properties-Title/Coding.

(2) We only need to choose UTF-8 as the encoding, and there is another choice: whether to include Unicode signature (bom) or not, and choose a format without BOM to save.

(3) If you find that some words are garbled, manually change them into corresponding Chinese, so that all template articles are converted into UTF-8 format!

Second, the database file conversion

(1) Back up the database files first to avoid file loss.

(2) Open phpMyAdmin to find the database file to edit, and export it locally.

(3) Open the export. The sql file is edited locally with Notepad++ or DW. Find CHARSET=gbk and replace it with CHARSET=utf8.

comment