Discuz教程网

ASP让url的中文显示为编码

[复制链接]
authicon dly 发表于 2011-9-10 21:27:28 | 显示全部楼层 |阅读模式
asp解码url
  1. <a href="1.asp?action=<%=server.urlencode("你好")%>">asdf</a>
复制代码

解码函数
  1. <%
  2. Function URLDecode(enStr)
  3. dim deStr,strSpecial
  4. dim c,i,v
  5. deStr=""
  6. strSpecial="!""#$%&'()*+,.-_/:;<=>?@[\]^`{|}~%"
  7. for i=1 to len(enStr)
  8. c=Mid(enStr,i,1)
  9. if c="%" then
  10. v=eval("&h"+Mid(enStr,i+1,2))
  11. if inStr(strSpecial,chr(v))>0 then
  12. deStr=deStr&chr(v)
  13. i=i+2
  14. else
  15. v=eval("&h"+ Mid(enStr,i+1,2) + Mid(enStr,i+4,2))
  16. deStr=deStr & chr(v)
  17. i=i+5
  18. end if
  19. else
  20. if c="+" then
  21. deStr=deStr&" "
  22. else
  23. deStr=deStr&c
  24. end if
  25. end if
  26. next
  27. URLDecode=deStr
  28. End function

  29. response.Write URLDecode(request.QueryString("action"))
  30. %>
复制代码




上一篇:ASP操作XML文件的完整实例代码
下一篇:SQL查询语句通配符与ACCESS模糊查询like的解决方法
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2025-5-2 10:38

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

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