안규 공부방

ACTIVE SERVER PAGE > URLDecode - ANSI - 디코딩 하자. URLDecode 함수

등록일 : 2017-07-04 18:12 조회수 : 92,922

http://ankyu.entersoft.kr/default.asp?id=123&usr=ankyu



http%3A%2F%2Fankyu%2Eentersoft%2Ekr%2Fdefault%2Easp%3Fid%3D123%26usr%3Dankyu


Server.URLEncode 를 통한 Encoding 된 데이터를 다시 Decode 하고 싶을 때가 있다. 이런경우는 IIS에서 자동으로 변환해 주지만, 함수를 만들어

보았다.

아래는 결과이다.
http://ankyu.entersoft.kr/default.asp?id=123&usr=ankyu


아래는 함수 소스 이다.
 
	Function URLDecode(sConvert)
		Dim aSplit
		Dim sOutput
		Dim I
	
		If IsNull(sConvert) Then
			URLDecode = ""
			Exit Function
		End If

		' convert all pluses to spaces
		sOutput = REPLACE(sConvert, "+", " ")

		' next convert %hexdigits to the character
		aSplit = Split(sOutput, "%")

		If IsArray(aSplit) Then
		sOutput = aSplit(0)
		
			For I = 0 to UBound(aSplit) - 1
				sOutput = sOutput & Chr("&H" & Left(aSplit(i + 1), 2)) & Right(aSplit(i + 1), Len(aSplit(i + 1)) - 2)
			Next
		End If

		URLDecode = sOutput
	End Function


 
※ 혹시 도움이 되셨다면 댓글에 한마디 남겨주세요!
작성자   비밀번호
자동글 방지     (자동글 방지 기능입니다.)
내용   댓글달기 
이메일 문의 : cak0280@nate.com  
Copyright 2000 By ENTERSOFT.KR All Rights Reserved.