asp urlDecode 在国外主机中文乱码

xxjhangzhou 2009-12-14 04:05:11
<%
Function urlDecode(enStr)
dim deStr,c,i,v : deStr=""
for i=1 to len(enStr)
c=Mid(enStr,i,1)
if c="%" then
v=eval("&h"+Mid(enStr,i+1,2))
if v<128 then
deStr=deStr&chr(v) : i=i+2
else
if isValidateHex(mid(enstr,i,3)) then
if isValidateHex(mid(enstr,i+3,3)) then v=eval("&h"+Mid(enStr,i+1,2)+Mid(enStr,i+4,2)) : deStr=deStr&chr(v) : i=i+5 else v=eval("&h"+Mid(enStr,i+1,2)+cstr(hex(asc(Mid(enStr,i+3,1))))) : deStr=deStr&chr(v) : i=i+3
else
destr=destr&c
end if
end if
else
if c="+" then deStr=deStr&" " else deStr=deStr&c
end if
Next
urlDecode=deStr
End Function

Function isValidateHex(str)
dim c
isValidateHex=true
str=ucase(str)
if len(str)<>3 then isValidateHex=false:exit function
if left(str,1)<>"%" then isValidateHex=false:exit function
c=mid(str,2,1)
if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isValidateHex=false:exit function
c=mid(str,3,1)
if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isValidateHex=false:exit function
End Function
response.write(urlDecode("%D3%A2%B3%AC%BE%AB%BB%AA%0D%0A"))
%>

解码 显示都是问号啊
...全文
97 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
mocom 2009-12-14
  • 打赏
  • 举报
回复
Public Function URLDecode(ByVal data, ByVal charset)
Dim strm
Set strm = Server.CreateObject("ADODB.Stream")
With strm
.type = 2
.charset = "iso-8859-1"
.open
.writeText unescape(data)
.position = 0
.charset = charset
URLDecode = .readText(-1)
.close
End With
Set strm = Nothing
End Function

Response.Write URLDecode("%B4%F3%BC%D2%BA%C3%B0%A1", "GB2312") & "<br/>"
Response.Write URLDecode("%E5%A4%A7%E5%AE%B6%E5%A5%BD%E5%95%8A", "UTF-8") & "<br/>"
xxjhangzhou 2009-12-14
  • 打赏
  • 举报
回复
那位高手指点 一下啊
xxjhangzhou 2009-12-14
  • 打赏
  • 举报
回复
报错 Microsoft VBScript runtime error '800a0005'

Invalid procedure call or argument: 'chr'
但是改成 chrw不报错但是 都是 问号

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧