Home > Web Front-end > JS Tutorial > HTML5 adds a solution to the problem of garbled characters in UTF-8 Chinese characters

HTML5 adds a solution to the problem of garbled characters in UTF-8 Chinese characters

一个新手
Release: 2017-09-27 09:55:02
Original
2334 people have browsed it


HTML5 adds utf-8 Chinese or is it garbled

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>
Copy after login

The reason is as follows:
There is no problem with the code itself, the problem lies with the editor. <meta charste="utf-8"> 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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template