Urlencode decoding function in ASP

xiaoxiao2021-04-05  322

Sometimes when passing some parameters, in order to avoid Chinese and some special characters, I often use the contents of the server.urlencode function, and the encoded decoding encounters problems. Can use Unescape in JS, how to decode in ASP ?

I searched online and found the following method. After testing, I can decode Chinese correctly:

Function URLDECode (ENSTR)

DIM DESTR, STRSPECIAL

DIM C, I, V

DESTR = ""

STRSPECIAL = "!" "# $% & '() * ,.-_ / :; <=>? @ [/] ^` {|} ~% "

For i = 1 to len (ENSTR)

C = MID (ENSTR, I, 1)

IF c = "%" THEN

v = evAl ("& H" MID (ENSTR, I 1, 2))

IF INSTR (STRSPECIAL, CHR (V))> 0 THEN

DESTR = Destr & Chr (v)

i = i 2

Else

v = EVAL ("& H" MID (ENSTR, I 1, 2) MID (ENSTR, I 4, 2))

DESTR = Destr & Chr (v)

i = i 5

END IF

Else

IF c = " " THEN

DESTR = destr & ""

Else

DESTR = DESTR & C

END IF

END IF

NEXT

URLDECode = destr

END FUNCTION

转载请注明原文地址:https://www.9cbs.com/read-132189.html

New Post(0)