The ultimate solution for passing garbled parameters on the gb2312 and UTF-8 pages of the same ASP site

Source: Internet
Author: User

①. The page files are correctly encoded. gb2312 adopts ANSI and UTF-8;
②. Set the correct CODEPAGE in ASP code. Use 936 for gb2312 and 65001 for UTF-8;
③ Set the correct charset in the HTML code. Use gb2312 and UTF-8 for gb2312;
④. Encode the passed parameter values using the js escape function;

Sample Code

T1.asp (ANSI code ):
Copy codeThe Code is as follows: <% @ LANGUAGE = "VBSCRIPT" CODEPAGE = "936" %>
<% Session. CodePage = 936%>
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> Page (gb2312) -jb51.net </title>
</Head>

<Body>
<Script type = "text/javascript">
Document. write ("<a href = 't2. asp? Keyword = "+ escape (" wooden house ") +" '> wooden house </a> ");
</Script>
<Br/>
<%
Response. Write (Request. QueryString ("keyword "))
%>
</Body>
</Html>

T2.asp (UTF-8 encoding ):
Copy codeThe Code is as follows: <% @ LANGUAGE = "VBSCRIPT" CODEPAGE = "65001" %>
<% Session. CodePage = 65001%>
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> Page (UTF-8) -jb51.net </title>
</Head>

<Body>
<Script type = "text/javascript">
Document. write ("<a href = 'T1. asp? Keyword = "+ escape (" wooden house ") +" '> wooden house </a> ");
</Script>
<Br/>
<%
Response. Write (Request. QueryString ("keyword "))
%>
</Body>
</Html>

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.