ASP garbled perfect solution

Source: Internet
Author: User

From: http://pcajax.javaeye.com/blog/569027

 

I used UTF-8 encoding on a new website today. I don't want to worry too much about it, so I found someArticle, Post, look at it, and paste it below when it is useful.
Today, I started to change codePage = "936"CodePage = "65001"
Change charset = gb2312Charset = 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.
Just add one sentence.<% 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 following text and you will know that I added this to all of them later,ProgramTop
<% 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 section to the conn. asp file of the gb2312 module:Code
<% @ 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%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.