找回密码
 立即注册
搜索
查看: 315|回复: 5

asp解码的问题

[复制链接]

36

主题

3824

回帖

2761

积分

论坛元老

问佛

积分
2761
发表于 2004-9-11 06:47:57 | 显示全部楼层 |阅读模式
%D6%D0%B9%FA%C8%CB

在asp中可以用Server.URLEncode把汉字变成如上代码
请问如何变回来?

在js中可以用unescape,vbs中如何做?

36

主题

3824

回帖

2761

积分

论坛元老

问佛

积分
2761
 楼主| 发表于 2004-9-11 14:44:27 | 显示全部楼层
;10 咋没有人知道?
回复

使用道具 举报

36

主题

3824

回帖

2761

积分

论坛元老

问佛

积分
2761
 楼主| 发表于 2004-9-12 19:17:47 | 显示全部楼层
天啦,三天了还没有人回。难道这么常见的问题都没有人碰到过吗?
回复

使用道具 举报

36

主题

3824

回帖

2761

积分

论坛元老

问佛

积分
2761
 楼主| 发表于 2004-9-14 02:00:59 | 显示全部楼层

终于找到方法了

CSDN上选择自 dyydyy 的 Blog 
URLDecode函数

function URLDecode(enStr)
        dim deStr
        dim 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 isvalidhex(mid(enstr,i,3)) then
                                  if isvalidhex(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
                                  end if  
                          else  
                                  destr=destr&c
                          end if
                        end if
                else
                        if c="+" then
                                deStr=deStr&" "
                        else
                                deStr=deStr&c
                        end if
                end if
        next
        URLDecode=deStr
end function


function isvalidhex(str)
        isvalidhex=true
        str=ucase(str)
        if len(str)<>3 then isvalidhex=false:exit function
        if left(str,1)<>"%" then isvalidhex=false:exit function
        c=mid(str,2,1)
        if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit function
        c=mid(str,3,1)
        if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit function
end function
回复

使用道具 举报

327

主题

3264

回帖

3641

积分

荣誉版主

积分
3641
发表于 2004-9-14 15:44:05 | 显示全部楼层
谢谢!

前2天就看了,但无奈asp不熟,也没使用过URLdecoding。 看了VBScript,谢谢!
回复

使用道具 举报

36

主题

3824

回帖

2761

积分

论坛元老

问佛

积分
2761
 楼主| 发表于 2004-9-15 04:18:20 | 显示全部楼层
用asp的人越来越少……
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|海浩社区

GMT+8, 2025-9-19 17:22 , Processed in 0.107436 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表