至此,全部原因已经分析清楚了。
因此说,保证asp叶面一定不会出现乱码的代码应该是这样的:(假定是UTF-8的叶子)
|
<%@ CODEPAGE=65001 %> <% Response.CodePage=65001%> <% Response.Charset="UTF-8" %> |
进一步说明为什么要加Response.Charset,因为MSDN说应该加...呵呵
|
If the code page is set in a page, then Response.Charset should also be set. |
另外,文件的编码格式应该与@CODEPAGE一样:
|
The file format of a Web page must be the same as the @CODEPAGE used in the page. |
这就是为什么zblog,pjblog等一些程序要吧文件存成UTF8编码格式的原因.
综上,如果所有的程序都声明了Response.CodePage就不会被Session.CodePage干扰而出现乱码了。所以Session.CodePage还是不能轻易用的!
参考文章:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iissdk/html/268f1db1-9a36-4591-956b-d7269aeadcb0.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iissdk/html/582e6f47-52eb-413e-8b5d-c99145cb61d8.asp









