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