urldecode 함수

asp에서는 URLEncode 함수만 제공 하고 decode함수는 제공하지 않는다.
iis에서 자동으로 처리하기 때문이라고 하는데..
파일에 쓴다든지 여러경우에 decode함수가 필요하다.
간단히 설명하면 + 는 공백으로 126이상의 ansi코드를 가져서 %다음에 16진수로 되어 있는것을 되돌리는 것이다.
유용하게 쓰시길
데브피아에서 참고

Function URLDecode(str)
Dim strTemp
Dim strChar
Dim strHex
Dim strHex1
Dim strDec
Dim strDec1
Dim lngCurrent
Dim nAsciiVal
Dim bDone
lngCurrent=1
While Not bDone

If Mid(str, lngCurrent, 1) = “+” Then
strTemp = strTemp & ” ”
lngCurrent = lngCurrent + 1

elseIf Mid(str, lngCurrent, 1) = “%” Then
strHex = Mid(str, lngCurrent + 1, 2)

If strHex <> “” Then
If CInt(“&H” & strHex) > 127 Then
lngCurrent = lngCurrent + 3
strHex1 = Mid(str, lngCurrent + 1, 2)
strDec = Chr(CInt(“&H” & strHex & strHex1))
strTemp = strTemp & strDec
lngCurrent = lngCurrent + 3

Else
strDec = Chr(CInt(“&H” & strHex))
strTemp = strTemp & strDec
lngCurrent = lngCurrent + 3
End If
End If
Else
strTemp = strTemp & Mid(str, lngCurrent, 1)
lngCurrent = lngCurrent + 1
End If

If lngCurrent > Len(str) Then
bDone = True
End If
Wend

URLDecode = strTemp

End Function

Comments

Powered by Facebook Comments

댓글 남기기

당신의 이메일은 공개되지 않습니다. 필수 입력창은 * 로 표시되어 있습니다.

*

다음의 HTML 태그와 속성을 사용할 수 있습니다: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>