我需要对VBScript中的字符串进行URL解码.该字符串可能包含Unicode字符,根据UTF-8编码为多个字节.因此,例如"巴黎%20%E2%86%92%20Z%C3%BCrich"将解码为"巴黎→苏黎世".
为了完成这项工作,我使用了一段代码如下:
Function URLDecode(str)
set list = CreateObject("System.Collections.ArrayList")
strLen = Len(str)
for i = 1 to strLen
sT = mid(str, i, 1)
if sT = "%" then
if i + 2 <= strLen then
list.Add cbyte("&H" & mid(str, i + 1, 2))
i = i + 2
end if
else
list.Add asc(sT)
end if
next
depth = 0
for each by in list.ToArray()
if by and &h80 then
if (by and &h40) = 0 then
if depth = 0 then …Run Code Online (Sandbox Code Playgroud)