网页汉字编解码,常用于网络对接
Function VFUnEscape(pstrInput)
Local i As Integer, c As String, d As Long
i = 1
UnEscape =[]
do While i <= Len(pstrInput)
c = substr(pstrInput, i, 1)
i = i + 1
If c = "%" Then
d = Val("0x" +substr(pstrInput, i, 2))
If d >=128 Then
d = d * 256 + Val("0x" +substr(pstrInput, i + 3, 2))
i = i + 5
Else
i = i + 2
endif
UnEscape = UnEscape + Chr(d)
Else
UnEscape = UnEscape + c
endif
enddo
return UnEscape
EndFunc
Function VFEscape(psString)
Local nTemp, sTemp, sTempChar, nTempAsc
sTemp=[]
For nTemp =1 To Len(psString)
sTempChar =substr(psString, nTemp, 1)
nTempAsc =ASC(sTempChar)
If (nTempAsc >=48 and nTempAsc <=57) or (nTempAsc >=65 and nTempAsc <=90) or (nTempAsc >=97 and nTempAsc <=122) or INlist(sTempChar,"@","*","_","+","-",".","/") Then
sTemp =sTemp+sTempChar
else
if nTempAsc >0 and nTempAsc <16 Then
sTemp =sTemp+"%0"+Hex(nTempAsc)
else
if nTempAsc >=16 and nTempAsc <256 Then
sTemp =sTemp+"%"+Hex(nTempAsc)
Else
sTemp =sTemp+"%u"+Hex(nTempAsc)
endif
endif
endif
Next
return sTemp
endfunc
Function Hex(lByte)
Local x,y
x=''
Do While lByte>0
If lByte>=16
Y=lByte%16
Else
Y=lByte
Endif
If Y<10 And Y>=0
x=Str(Y,1)+x
Else
x=Chr(65+Y-10)+x
Endif
lByte=(lByte-Y)/16
Enddo
Return x
Endfunc&&补充一个