"; 2. Pass "" mode setting."/> "; 2. Pass "" mode setting.">
Home >Web Front-end >Front-end Q&A >How to set character set in html
htmlHow to set the character set: 1. Use "09477266eebbc8a01f42387ae29e71dd"; 2. Pass "679669730644ab6dc84f22ee9afa4251" method.
The operating environment of this article: windows7 system, HTML5&&CSS3 version, DELL G3 computer.
html Two ways to specify the page character set
Method 1 :
<meta charset="utf-8">
Method 2:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
The above are two ways to set the character set of the page to UTF-8 (setting the page character set). The purpose is to tell the browser about the html file character set.
The first: the server specifies the character set of the response content;
response.setCharacterEncoding("utf-8")
Premise: The server forwards or redirects to the specified interface through the server.
Second type: page-specified character set.
See 1
Note: The first method has higher priority than the second method.
HTML video tutorial]
Solution If it is forwarding, you need to specify the character set of the returned data as utf-8 That’s it.response.setCharacterEncoding("utf-8");4. Server redirection If the page is redirected and the encoding set of the returned data is not specified, what will happen to the page? The character set is determined by the page, that is, the character set of the page is determined by the statement about the character set on the page. For example: if the character set specified on the page is: iso-8859-1
##, then the browser will parse it according to iso-8859-1.
In addition, even if the redirection sets the encoding set of the returned data, it will be invalid because: redirection will cause data loss!
Summary
Note: Today we are talking about the page character set problem and the garbled characters that appear during pure data interaction are not the same thing!
In addition, if the character set is specified in both the HTTP response header and meta, a conflict will occur, and the character set of the http response will take effect.
The above is the detailed content of How to set character set in html. For more information, please follow other related articles on the PHP Chinese website!