ASP在网页中显示乱码,代码如下谢谢

<!--#include file="connection.asp"--><style type=text/css>
body {
scrollbar-face-color: #71D63D;
scrollbar-highlight-color: #71D63D;
scrollbar-shadow-color: #71D63D;
scrollbar-3dlight-color: #ffffff;
scrollbar-arrow-color: #ffffff;
scrollbar-track-color: #ffffff;
scrollbar-darkshadow-color: #ffffff;
}
td
{
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size: 9pt;
line-height: 150%;
color: #333333;

}
a {text-decoration:none}
a:hover {color: #666666;text-decoration:none}
</style>
<script language=JavaScript>
function KB_keepItInIE(theName,theWantTop,theWantLeft) {
theRealTop=parseInt(document.body.scrollTop)
theTrueTop=theWantTop+theRealTop
document.all[theName].style.top=theTrueTop
theRealLeft=parseInt(document.body.scrollLeft)
theTrueLeft=theWantLeft+theRealLeft
document.all[theName].style.left=theTrueLeft
}
function KB_keepItInNN(theName,theWantX,theWantY) {
theRealLay=document.layers[theName]
theBadX=self.pageYOffset
theBadY=self.pageXOffset
theRealX=theBadX+theWantX
theRealY=theBadY+theWantY
theRealLay.moveTo(theRealY,theRealX)
}
IE4=(document.all)?1:0
NN4=(document.layers)?1:0
if (IE4)
setInterval('KB_keepItInIE("KBStatic",0,0)',1)
if (NN4)
setInterval('KB_keepItInNN("KBStatic",0,0)',1)
</script>
<body alink="#333333" link="#333333" vlink="#333333">
<div id="KBStatic" style="position:absolute; left:0px; top:0px; width:100%; height:23px; z-index:25">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<%
set rs11=conn.execute("select id,board from board")
while not rs11.eof
%>
<td height=24 bgcolor=#71D63D align=center><a href="xl_list.asp?action=edit&id= <%=rs11("id")%>"><font color="#FFFFFF"><%=(rs11("board"))%></font></a></td>
<%
rs11.movenext
wend
%>
</tr>
</table>
</div>
<%
rs11.close
%>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
<tr align="center" bgcolor="#f5f5f5">
<td width="321" height="21" bgcolor="#71D63D"> </td>
<td width="124" bgcolor="#71D63D">预定</td>
</tr>
<%
dim id
id=trim(request("id"))
if id="" or not isnumeric(id) then
tt="select top 20 id,x_name,x_leiid,x_top from xianlu order by x_top desc"
else
tt="select id,x_name,x_leiid,x_top from xianlu where x_leiid="&id&" order by x_top desc"
end if
set er=conn.execute(tt)
while not er.eof
%>
<tr bgcolor="#FFFFFF">
<td height="24" bgcolor="#EFEFEF">
<%
if trim(er("x_top"))=1 then
%>
  <img src="images/top.gif"> 
<%
else
%>
  <img src="images/ping.gif">
<%
end if
%>
<a href="Xl/Xl_<%=er("id")%>.html" target="_blank"><%=er("x_name")%></a></td>
<td align="center" bgcolor="#EFEFEF"><a href="Giveme.asp?id=<%=er("id")%>" title='预定' target="_blank">预定</a></td>
</tr>
<%
er.movenext
wend
er.close
%>
</table>
</body>

1.若是html文件(.htm .html):
在<head></head>中加上<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
2.若是PHP/cgi文件(.php .php3 .php4):
在每个PHP文件第一行加上<?header("content-Type: text/html; charset=gb2312"; ?>

3.若是asp文件(.asp .jsp):
下面言归正传,说说asp源文件在国外服务器上中文问题的解决办法:

1.首先,把您的asp源文件放在 IIS 里进行全面测试,调用每一项功能,确认它完全能够使用,并正确显示中文,并打开 *.mdb 数据库文件查看中文显示是否正常。全部通过后,做好备份文件,即可执行第二步。

2.如果,您根本不懂 asp 的话,最简单的方法是:
打开 所有 *.asp 文件,并在第一行插入 <%@ codepage="936" %>,

例外情况:
①,如果第一行是以 <%@ LANGUAGE="VBSCRIPT" %> 开头,
则把第一行改为:<%@ codepage="936" LANGUAGE="VBSCRIPT" %>

②,如果第一行是以 <html> 或 <SCRIPT LANGUAGE="javascript">开头,则不加入。

3.第二步完成后,再用 IIS 对每一项功能进行测试,如显示 \0\conn.asp line 1, 即为错误信息,意思是: conn.asp 源文件第一行有错,那就把 <%@ codepage="936" %> 删除即可,一些例外错误,请到 http://search.microsoft.com/default.asp ;这里,输入“错误信息”查询即可,全部功能测试可行后,即可上传至国外服务器上,进行测试。

4.方法还是:调用每一项功能,全部能正确使用并能显示中文后,再“下传”*.mdb 文件(非常重要),打开,确认能正确显示中文,大功告成。

另外在外国服务器上用ACESS2000的中文显示方法不用转化数据库ACESS2000,只需在ASP第一行加入<%@ codepage=1256 %>

怎么解决外国空间中文显示出问题的问题
非程序生成的文字可以显示。但程序生成的文字就只有E文可以显示了。中文全是?号,这是数据库乱码引起的。

方法一:
使用 Microsoft Access 2000 打开数据库,选择工具菜单>数据库实用工具>转换数据库>到早期 Access 数据库版本。OK!

方法二:

后来订阅了微软的新闻组,在微软的新闻组dotnet.framework.aspplus.general中发现有讨论这
个问题的文章,方法为添加<%@ CODEPAGE = "936" %>到每一页的开头,有点类似于jsp中的
<%@ page contentType="text/html;charset=gb2312"%>
赶紧测试了一下,果然OK!!!

例子如下面所示:
<%@ CODEPAGE = "936" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.ADO" %>
<%@ Import Namespace="System.Globalization" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

方法三:

在翻阅了微软NGWS文档后发现在文档的常见问题部分有提到要添加一个config.web文件到
web目录下,试了一下,中文显示果然OK了。
方法如下:

建立一个文件config.web,内容如下,放在WEB目录下
<configuration>
<globalization
requestencoding="utf-8"
responseencoding="utf-8"
/>
</configuration>

DISCUZ论坛对付国外空间乱码最简单的办法

DISCUZ论坛对付国外空间乱码最简单了,在它的配置文件config.php里找到这句:
$headercharset = 1; // 强制设置字符集, 0=否, 1=是. 乱码时使用

将等号后面修改成1就可以了,无须修改其它文件。
其实很简单,但是注意到的人不多:)

参考资料:http://www.axyz.cn/index.asp?tjrmb=%u6211%u5FC3%u98DE%u626C&boardid=40

温馨提示:答案为网友推荐,仅供参考
第1个回答  2007-01-30
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
在最前面加上这个

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网