打印

utf-8与gb2312的使用

想做一个网站,需要利用到sq了,那么到底用那种编码方式那
网上对于utf-8和gb2312的使用有比较多的讨论
但是到底用哪一种编码方式比较好呢

再有就是我利用两种不同的编码方式,表单传输过来的中文参数是:%3f%c9%7b%84%3dP

怎么才能转化成中文呢

同上

编码进行urldecode之后,得到的是乱码
如何解决
程序如下:
发送页面:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
。。。。。。。
<anchor>Post方式提交<go href="1main.asp" method="post">
<postfield name="name" value="$(name:e)" />
<postfield name="paword" value="$(paword:e)" />
</go>
</anchor>
==============================
接受页面:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
username=Request.Form("name")
password=Request.Form("paword")
Response.ContentType="text/vnd.wap.wml"
%><?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"

"http://www.wapforum.org/DTD/wml_1.1.xml">
。。。。。。。。。。。
username:<%=URLDecode(username)%>
======================
输入:天南地北
输出:)W0

[ 本帖最后由 itgirl 于 2006-12-7 17:25 编辑 ]

urldecode函数

<%
Function URLDecode(enStr)                    'URL解碼函數
  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
%>