1. Methods to solve the problem of Chinese garbled characters in HTML
1. Add UTF8 encoding (international encoding) in the head tag: UTF-8 is a country-less encoding, which is independent of any language or any language. All can be used.
2. Save the file encoding as UTF-8. Editors such as Notepad or Editplus have the function of selecting encoding when saving.
2. HTML and PHP mixed page solution
In addition to following the operations mentioned in the first method, you also need to add this code at the top of the file:
header("Content-type:text/html;charset=utf-8");
?>
3. The Chinese garbled problem of pure PHP pages (the data is static)
For this, you only need to add the following code at the beginning of the page, and then save the UTF-8 encoded file.
header("Content-type:text/html;charset=utf-8");
?>
4. PHP Mysql Chinese garbled problem
In addition to following the operations mentioned in the third point, you must also add database encoding before querying/modifying/adding your data. Moreover, it is worth noting that the UTF8 here is different from the previous one, there is no horizontal line in the middle.
mysql_query('SET NAMES UTF8');
//The next step is to find the data or modify it, add
?>
5. Correctly display the Chinese name of the uploaded attachment
Find the file config.php in xampp/moodle,
Add $CFG->unicodedb = true; after $CFG->unicodecleanfilename = true;
Then the attachment uploaded by Modeng can be Display Chinese names correctly.
6. When selecting to upload files in the IE browser, garbled characters may be displayed. You can select the file in
lib/editor/htmlarea/coursefiles.php
Add this sentence to the second line: // You can use:set nu to display the line number
@header("Content-Type: text/html; charset=utf-8"); //This is the default selection of utf-8 encoding