1. 程式人生 > >php(utf8)跨站到asp(gb2312)亂碼問題

php(utf8)跨站到asp(gb2312)亂碼問題

1、首先必須明確utf-8頁面上的utf-8編碼的內容才符合真正的utf-8字符集,同理gb2312
2、因此兩邊的字符集必須是相應的字符集(meta或者header定義字元的部分)
3、先解決utf-8的php頁面的字元傳參到gb2312的asp頁面亂碼的問題(此處參考:

http://blog.csdn.net/jinxbin/article/details/5683473)
    |-接受引數的asp頁面的最頂部加入
        <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>  
                <%  
                  Response.CodePage=65001   
                  Response.Charset="UTF-8"    
                %>
    |-接受引數的asp頁面在需要顯示接受的資料之前加入
         <%
                    response.codepage=936  
           response.charset="GB2312"
         %>
    這樣普通字元都可正常顯示,但是html格式的字元卻無法正常顯示
4、在接受到的html格式的引數處使用:Server.Htmlencode(utf8str)函式
    neirong = Server.Htmlencode(Request.Form("neirong"))
5、至此,頭疼兩天的轉碼問題解決