本帖最后由 wankoilz 于 2011-6-1 11:09 编辑
我这有个vbs,你参考下:- Function URLEncoding(vstrIn)
- strReturn = ""
- For i = 1 To Len(vstrIn)
- ThisChr = Mid(vStrIn,i,1)
- If Abs(Asc(ThisChr)) < &HFF Then
- strReturn = strReturn & ThisChr
- Else
- innerCode = Asc(ThisChr)
- If innerCode < 0 Then
- innerCode = innerCode + &H10000
- End If
- Hight8 = left(cstr(hex(innerCode)),2)
- Low8 = right(cstr(hex(innerCode)),2)
- strReturn = strReturn & "%" & Hight8 & "%" & Low8
- End If
- Next
- URLEncoding = strReturn
- End Function
-
- Function URLUncoding(code)
- str="0123456789abcdef"
- set reg=new regexp
- reg.ignoreCase=true
- reg.global=true
- reg.pattern="%\w\w%\w\w"
- set matches=reg.execute(code)
- for each matche in matches
- matche=replace(matche,"%","")
- sum=0
- for i=1 to 4
- singlechr=mid(matche,i,1)
- number=instr(1,str,Lcase(singlechr),1)-1
- sum=sum+number*16^(4-i)
- next
- word=chr(sum-65536)
- URLUncoding=URLUncoding&word
- next
- End Function
-
- s=inputbox("输入Code或中文")
- If inStr(s,"%") then
- return=msgbox(URLUncoding(s),0,"结果")
- Else
- return=msgbox(URLEncoding(s),0,"结果")
- End if
复制代码 抱歉,刚才仓促回帖,没注意到是utf-8,这个vbs只支持gbk |