Home > Article > Web Front-end > HTML5 adds a solution to the problem of garbled characters in UTF-8 Chinese characters
Foreword: The editor I use is EditPlus
Recently, I was studying HTML5. I compared the relevant textbooks and typed out the following code, and also set the encoding format, but the title was indeed garbled when displayed. The code is as follows:
<!DOCTYPE html><html><head> <meta http-equiv="Content-Type"content="text/html;charset=UTF-8"> <!-- <meta charset="UTF-8"> --><title>是否支持h5</title> <style type="text/css"> #myCanvas{ background:red; width:200px; height:100px; } </style></head><body> <canvas id="myCanvas">该浏览器不支持HTML5的画布标记!</canvas> </body></html>
The reason is as follows:
There is no problem with the code itself, the problem lies with the editor. 3c04f8307b92f2b6b370302b03752be4
just tells the browser to use utf-8
for interpretation, but the encoding of the document itself is determined by the selection when saving. , if you save it using ANSI
and then use utf-8
to interpret it, it will definitely be garbled. The default file format saved by the editor and Notepad is ANSI
, so Change it to utf-8
when saving.
Attachment:
How to modify the encoding method of the corresponding editor EditPlus configuration:
1. Chinese version of EditPlus setting method:
Click "Tools" — —>Select "Configure User Tools" —>In the window that opens, select "File" —>Select the default encoding encoding method, as shown in the figure, select "utf-8" —> Then click Confirm .
Exit the software, create a new file, copy the above code, and save the new file in UIF-8 encoding format.
2. Setting method for English version of EditPlus:
Tools ——>Configure user Tools…——>Click “File”——>Set Default encoding to UTF-8——>Then Click "Apply" to save.
Exit the software, create a new file, copy the above code, and save the new file in UIF-8 encoding format.
name: OOLD
code: A8F04-F7160-1C99F-79CDB-F4CE8
The above is the detailed content of HTML5 adds a solution to the problem of garbled characters in UTF-8 Chinese characters. For more information, please follow other related articles on the PHP Chinese website!