To solve the problem of garbled parameter transmission in gb2312 and utf-8 pages under the same ASP site, you only need to strictly follow the following four points. ①. Use the correct encoding for the page file, gb2312 uses ANSI, and utf-8 uses utf-8;
②.Set the correct CODEPAGE in the ASP code, use 936 for gb2312, and 65001 for utf-8;
③.Set the correct charset in the HTML code, use gb2312 for gb2312, and use utf-8 for utf-8;
④. Encode the passed parameter value using the escape function of js;
Sample code
t1.asp (ANSI encoding):
Copy the code code 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)-vevb.com</title>
</head>
<body>
<script type=text/javascript>
document.write(<a href='t2.asp?keyword= + escape(木子屋) + '>木子屋</a>);
</script>
<br/>
<%
Response.Write(Request.QueryString(keyword))
%>
</body>
</html>
t2.asp (utf-8 encoding):
Copy the code code 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)-vevb.com</title>
</head>
<body>
<script type=text/javascript>
document.write(<a href='t1.asp?keyword= + escape(木子屋) + '>木子屋</a>);
</script>
<br/>
<%
Response.Write(Request.QueryString(keyword))
%>
</body>
</html>