經典ASP_表單提交參數語法及編碼校正_網址傳參數顯示於網頁中會中文亂碼的問題排除


近期又回到考古學者的身分
開始又接觸到Active Server Page 跟 Crystal Report
剛好在第二份工作都有摸過這些老東西XDD



 
稍微溫故 暖身
筆記一下






起初程式碼會於解析get 網址後綴參數有誤擷取的問題,沒依照key1=val1&key2=val2方式作正確擷取

程式碼

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
<HTML>
<HEAD>

</HEAD>

<BODY>


<%

name = Request("name")
Response.write "name:" & name & "<br />"
name1 = Request("actor")
Response.write "actor:" & name1 & "<br />"

%>

</BODY>

</HTML>





Step1.先調整此頁程式碼的codepage

codepage指定了IIS按什麼編碼讀取傳遞過來的串串(表單提交,地址欄傳遞等)。
在此先改為UTF8
讓沒按照key1=val1&key2=val2方式作正確擷取可排除



程式碼

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
<%@ codepage=65001%>
<HTML>
<HEAD>

</HEAD>

<BODY>


<%

name = Request("name")
Response.write "name:" & name & "<br />"
name1 = Request("actor")
Response.write "actor:" & name1 & "<br />"

%>

</BODY>

</HTML>



Step2. charset 用來指定網頁內容是用什麼編碼
在此設置UTF8 瀏覽器就會以 UTF-8 來載入




程式碼

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
<%@ codepage=65001%>
<HTML>
<HEAD>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</HEAD>

<BODY>


<%

name = Request("name")
Response.write "name:" & name & "<br />"
name1 = Request("actor")
Response.write "actor:" & name1 & "<br />"

%>

</BODY>

</HTML>










Ref:
https://medium.com/@mingjunlu/using-the-meta-tag-to-declare-character-encodings-in-html-b04546ed7ae9
https://www.fooish.com/html/meta-charset.html
http://www.aspphp.online/bianchen/wangye/asp/asprm/201701/109107.html
http://www.study-area.org/coobila/tutorial_337.html
https://www.cnblogs.com/huangtailang/p/b5eeedf607635347ffce9ec0f9640b6e.html
https://dotblogs.com.tw/corner/2010/03/14/14021
http://dept.pjhs.tyc.edu.tw/ASPHTML/
http://itchen.class.kmu.edu.tw/XML/XMLTech/eBook/%AA%FE%BF%FDD.pdf
http://www.perfume.com.tw/newtalk/forum_topics.asp?FID=4
http://itchen.class.kmu.edu.tw/XML/XMLTech/eBook/%AA%FE%BF%FDD.pdf
https://w3.nhps.tp.edu.tw/cptech/upload/%E6%9C%B1%E5%AD%9D%E5%9C%8B%E7%9A%84%E7%AD%86%E8%A8%98%E6%9C%AC%20Peter%20Ju's%20Notebook.htm
https://sdwh.dev/posts/2020/08/ASP-Maintenance/
https://blogs.iis.net/nazim/filtering-sql-injection-from-classic-asp






留言

這個網誌中的熱門文章

何謂淨重(Net Weight)、皮重(Tare Weight)與毛重(Gross Weight)

Architecture(架構) 和 Framework(框架) 有何不同?_軟體設計前的事前規劃的藍圖概念

(2021年度)駕訓學科筆試準備題庫歸納分析_法規是非題