I am using UTF-8 encoding on a new website today. I don't want to worry too much about it. So I found some articles, posts, and views. I will post the following useful articles.
Today, I started to change codePage = "936" to codePage = "65001"
Change charset = gb2312 to charset = UTF-8
But it is still garbled. As long as the script is used or garbled, the problem is finally found, that is, when the script is output, it must be output in UTF-8 encoding.
<% Response. charset = "UTF-8" %>
First of all, of course, the page itself with UTF-8 encoding, the default encoding in DW new page as "Unicode (UTF-8 )"
<% @ Language = "VBScript" codePage = "65001" %>
'② CodePage = "65001" tells the server page to use UTF-8-encoded
<HTML>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
'③ Charset = UTF-8 tells the browser that the page uses UTF-8 Encoding
</Head>
<Body>
<% Response. charset = "UTF-8" %>
④ The server output code is UTF-8.
</Body>
</Html>
Dizzy, it's not over yet
Just happy, the problem came out. After refreshing it, it turned into garbled code, or when I browsed other gb2312 pages, I came back and garbled again. It's worth another Google visit.
Take a look at the text below, and you will know that after I add this, the top of the program
<% Session. codePage = 65001%>
<% @ CodePage = 936%> Simplified Chinese
<% @ CodePage = 950%> traditional Chinese
<% @ CodePage = 65001%> UTF-8
CodePage specifies the encoding used by IIS to read passed strings (such as form submission and address bar transfer ).
The cause of garbled characters is that the module encoding is different when the website is to be integrated.
Do not convert the encoding of the webpage in any module, such as UTF-8 or UTF-8, or gb22312 or gb2312.
Add the following code to the conn. asp file of the gb2312 module:
<% @ Language = "VBScript" codePage = "936" %>
<% Session. codePage = 936%>
Everything is OK!
Also in the package file of the Utf-8 module (such as Conn. asp, but note that conn. asp must be at the beginning of the first line of CALL) add
<% @ Language = "VBScript" codePage = "65001" %>
<% Session. codePage = 65001%>
During the past few days, I have encountered gibberish and depressing things. I have never studied encoding before, But I just used the statements directly! After my research in the afternoon, I came to the following conclusion!
First, select encoding: You must select encoding according to the content on your page. However, we recommend that you use UTF-8 encoding in the foreground and backend by adding the following content to conn. asp:
Reference <% @ codePage = 65001%>
<% Response. codePage = 65001%>
<% Response. charset = "UTF-8" %>
You can solve the hidden danger of Garbled text, or add it to each page at the beginning:
<Meta HTTP-EQUIV = "Content-Type" content = "text/html; charset = UTF-8"/>
If there is a small page, the ASP server directly declares <% response. charset = "UTF-8" %>, which can basically solve the garbled problem!
Second, if a page does not require UTF-8 encoding, add the following directly: <% response. charset = "gb2312" %>
Another problem is that a page is UTF-8 encoded, while another page is gb2312 encoded. How to redirect without garbled characters. The method is:
Set session. codePage = 936 for the gb2312 page, or directly use response. Redirect to redirect.
In addition, basic knowledge:
<% @ CodePage = 936%> Simplified Chinese
<% @ CodePage = 950%> traditional Chinese
<% @ CodePage = 65001%> UTF-8