function?URLEncode(nstr)
創新互聯,為您提供重慶網站建設公司、成都網站制作公司、網站營銷推廣、網站開發設計,對服務成都自上料攪拌車等多個行業擁有豐富的網站建設及推廣經驗。創新互聯網站建設公司成立于2013年,提供專業網站制作報價服務,我們深知市場的競爭激烈,認真對待每位客戶,為客戶提供賞心悅目的作品。 與客戶共同發展進步,是我們永遠的責任!
For?i?=?1?To?Len(nstr)
nmid=Mid(nstr,?i,?1)
nasc=Asc(nmid)
if?nasc??0?Then
nhex=right("000"??Hex(nasc),4)
URLEncode?=?URLEncode??"%"??Left(nhex,?2)??"%"??Right(nhex,?2)
elseif?nmid="?"?then
URLEncode?=?URLEncode??"+"
Elseif?(nasc?=?48?And?nasc?=?57)?Or?(nasc?=?65?And?nasc?=?90)?Or?(nasc?=?97?And?nasc?=?122)?Then
URLEncode?=?URLEncode??nmid
Else
URLEncode?=?URLEncode??"%"??right("0"??Hex(nasc),2)
End?if
Next
end?function
樓主啊。。我還沒用過這種方法轉到網頁的..其實用WebBrowser1.Navigate ()即可實現網頁轉到
'編碼函數
Public?Function?URLEncode(ByRef?strURL?As?String)?As?String?
Dim?I?As?Long?
Dim?tempStr?As?String?
For?I?=?1?To?Len(strURL)?
If?Asc(Mid(strURL,?I,?1))??0?Then?
tempStr?=?"%"??Right(CStr(Hex(Asc(Mid(strURL,?I,?1)))),?2)?
tempStr?=?"%"??Left(CStr(Hex(Asc(Mid(strURL,?I,?1)))),?Len(CStr(Hex(Asc(Mid(strURL,?I,?1)))))?-?2)??tempStr?
URLEncode?=?URLEncode??tempStr?
ElseIf
(Asc(Mid(strURL,?I,?1))?=?65?And?Asc(Mid(strURL,?I,?1))?=?90)?
Or?(Asc(Mid(strURL,?I,?1))?=?97?And?Asc(Mid(strURL,?I,?1))?=?
122)?Then?
URLEncode?=?URLEncode??Mid(strURL,?I,?1)?
Else?
URLEncode?=?URLEncode??"%"??Hex(Asc(Mid(strURL,?I,?1)))?
End?If?
Next?
End?Function?
'解碼函數
Public?Function?URLDecode(ByRef?strURL?As?String)?As?String?
Dim?I?As?Long?
If?InStr(strURL,?"%")?=?0?Then?URLDecode?=?strURL:?Exit?Function?
For?I?=?1?To?Len(strURL)?
If?Mid(strURL,?I,?1)?=?"%"?Then?
If?Val("H"??Mid(strURL,?I?+?1,?2))??127?Then?
URLDecode?=?URLDecode??Chr(Val("H"??Mid(strURL,?I?+?1,?2)??Mid(strURL,?I?+?4,?2)))?
I?=?I?+?5?
Else?
URLDecode?=?URLDecode??Chr(Val("H"??Mid(strURL,?I?+?1,?2)))?
I?=?I?+?2?
End?If?
Else?
URLDecode?=?URLDecode??Mid(strURL,?I,?1)?
End?If?
Next?
End?Function
這是中文編碼你沒設置好。首先在Dreamweaver CS4里面,選擇》》編輯》》首先參數》》 左側選擇 新建文檔》》》默認編碼》》簡體中文gb2312.ok新建文檔。把你原來的代碼粘貼進去,最好重新寫一下。測試
%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""
html xmlns=""
head
meta http-equiv="Content-Type" content="text/html; charset=gb2312" /
title解決中文亂碼問題/title
/head
body
%
if request.QueryString("j")="j" then
response.write (request.Form("user"))
end if
%
form name="form1" method="post" action="?j=j"
label
input type="text" name="user" id="user"
/label
label
input type="submit" name="button" id="button" value="提交"
/label
/form
/body
/html
用我直接給你寫的也ok
添加兩個text,和一個按鈕,點按鈕之后text1的內容就會轉換為UTF-8的URL編碼Function GBtoUTF8(szInput)
Dim wch, uch, szRet
Dim x
Dim nAsc, nAsc2, nAsc3'如果輸入參數為空,則退出函數
If szInput = "" Then
GBtoUTF8 = szInput
Exit Function
End If'開始轉換
For x = 1 To Len(szInput)
wch = Mid(szInput, x, 1)
nAsc = AscW(wch)If nAsc 0 Then nAsc = nAsc + 65536If (nAsc And HFF80) = 0 Then
szRet = szRet wch
Else
If (nAsc And HF000) = 0 Then
uch = "%" Hex(((nAsc \ 2 ^ 6)) Or HC0) Hex(nAsc And H3F Or H80)
szRet = szRet uch
Else
uch = "%" Hex((nAsc \ 2 ^ 12) Or HE0) "%" _
Hex((nAsc \ 2 ^ 6) And H3F Or H80) "%" _
Hex(nAsc And H3F Or H80)
szRet = szRet uch
End If
End If
Next
GBtoUTF8 = szRet
End Function
Private Sub Command1_Click()
Text2.Text = GBtoUTF8(Text1.Text)
End Sub
分享標題:包含vb.neturl轉碼的詞條
URL鏈接:http://m.kartarina.com/article46/dodspeg.html
成都網站建設公司_創新互聯,為您提供全網營銷推廣、自適應網站、用戶體驗、建站公司、企業網站制作、動態網站
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯