Today I encountered the problem of Chinese garbled characters while learning HTML5:
<body> <form > 请输入内容: <input pattern="[A-Z]{3}" name="part"> <input type="submit"> </form> </body>
I developed it using myeclipse 2016, but the encoding format of my project and html file are both utf-8, which is still garbled. I searched online. I couldn't find it in the search, but later I found an interesting thing and learned the cause of the problem.
Every time you create a new HTML5 file, the new file comes with the following code:
<meta name="keywords" content="keyword1,keyword2,keyword3"> <meta name="description" content="this is my page"> <meta name="content-type" content="text/html; charset=UTF-8">
But I tried to change
<meta name="content-type" content="text/html; charset=UTF-8">
to the following
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
The problem of garbled characters is solved.
Then I went to google to find out the difference between http-equiv and name:
They said this: "nameattribute is mainly used to describe web pages", while http -equiv "is equivalent to the http file header. It can return some useful information to the browser to help display the web page content correctly and accurately."
After seeing this, I think it can be roughly explained, It’s just that you may need to change it every time in future development (I tried deleting all these meta attributes, but when the project was run, the Chinese characters were still garbled...).
The above is the detailed content of Chinese garbled characters problem. For more information, please follow other related articles on the PHP Chinese website!