ASP 에서 사용하실 수 있는 URL Decode 함수 입니다.
찾아보니 ASP 에서는 URL encode 는 내장함수로 지원을 하는데 decode 는 지원하지 않는것 같더군요...

그래서 decode 는 아래 함수를 활용해서 사용하시면 됩니다.

  1. Public Function URLDecode(str)
  2.  
  3.     Dim strTemp
  4.     Dim strChar
  5.     Dim strHex
  6.     Dim strHex1
  7.     Dim strDec
  8.     Dim strDec1
  9.     Dim lngCurrent
  10.     Dim nAsciiVal
  11.     Dim bDone
  12.     lngCurrent=1
  13.    
  14.     While Not bDone
  15.  
  16.         If Mid(str, lngCurrent, 1) = "%" Then
  17.            
  18.             strHex = Mid(str, lngCurrent + 1, 2)
  19.  
  20.             If strHex <> "" Then
  21.                 If CInt("&H" & strHex) > 127 Then
  22.                     lngCurrent = lngCurrent + 3
  23.                     strHex1 = Mid(str, lngCurrent + 1, 2)
  24.                     strDec = Chr(CInt("&H" & strHex & strHex1))
  25.                     strTemp = strTemp & strDec
  26.                     lngCurrent = lngCurrent + 3
  27.                 Else
  28.                     strDec = Chr(CInt("&H" & strHex))
  29.                     strTemp = strTemp & strDec
  30.                     lngCurrent = lngCurrent + 3
  31.                 End If
  32.             End If
  33.  
  34.         Else
  35.            
  36.             strTemp = strTemp & Mid(str, lngCurrent, 1)
  37.             lngCurrent = lngCurrent + 1
  38.  
  39.         End If
  40.  
  41.         If lngCurrent > Len(str) Then
  42.             bDone = True
  43.         End If
  44.    
  45.     Wend
  46.  
  47.     URLDecode = strTemp
  48.  
  49. End Function


 

이 글은 사람™이(가) 썼어요.