Home >Web Front-end >H5 Tutorial >Chinese garbled characters problem

Chinese garbled characters problem

大家讲道理
大家讲道理Original
2017-05-28 10:43:264540browse

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!

Statement:
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
Previous article:canvas dynamic chartNext article:canvas dynamic chart