静态页面utf-8编码客户端打开空白问题

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/virone/article/details/4242240

注意title与meta申明之间的位置,title中如果有中文,在还未申明此文档是何编码之前便发送客户端浏览器,便会出现显示空白问题. 例:

错误写法:

<head>
<title>JHDLAB - 全球领先的实验室产品直接供应商</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

正确写法:

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JHDLAB - 全球领先的实验室产品直接供应商</title>
</head>

展开阅读全文

asp生成静态页面编码utf-8问题

01-20

大家好,asp生成静态页面,生成的是unicode编码,但我需要生成的是utf-8,代码如下rnrnFunction createhtml(url,filename,path) rnSet MyFileObject=Server.CreateObject("Scripting.FileSystemObject")rnpath1=server.mappath(path)&"\"&filenamernSet MyTextFile=MyFileObject.CreateTextFile(path1,True,true)rnstrurl=url rnstrTmp = GetHTTPPage(trim(strurl))rnMyTextFile.WriteLine(strTmp)rnMytextFile.ClosernSet MyFileObject=nothingrnresponse.Write " "rnEnd functionrnrnFunction getHTTPPage(url) rn On Error Resume Nextrn dim http rn set http=Server.createobject("Microsoft.XMLHTTP") rn Http.open "GET",url,false rn Http.send() rn if Http.readystate<>4 thenrn exit function rn end if rn getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")rn set http=nothingrn If Err.number<>0 then rn Response.Write " 服务器获取文件内容出错" rn Err.Clearrn End If rnEnd FunctionrnrnFunction BytesToBstr(body,Cset)rn dim objstreamrn set objstream = Server.CreateObject("adodb.stream")rn objstream.Type = 1'设置为可读可写 rn objstream.Mode =3'设置内容为文本rn objstream.Openrn objstream.Write bodyrn objstream.Position = 0rn objstream.Type = 2rn objstream.Charset ="UTF-8"rn BytesToBstr = objstream.ReadText rn objstream.Closern set objstream = nothingrnEnd FunctionrnrnFunction timetohtml(str)rn timetohtml=Replace(Replace(Replace(str,":",""),"-","")," ","")&".html"rnEnd FunctionrnrnFunction finddir(filepath)rn finddir=""rn for i=1 to len(filepath)rn if left(right(filepath,i),1)="/" or left(right(filepath,i),1)="\" thenrn abc=irn exit forrn end ifrn nextrn if abc <> 1 thenrn finddir=left(filepath,len(filepath)-abc+1)rn end ifrnend Functionrnrnurl="http://" & Request.ServerVariables("http_host") & finddir(Request.ServerVariables("url"))rnrnrnurl0=""&url&"" '这个为页面地址rnrnpath="../html" rn rnfilename="index.html" rnurl=url0&"list.asp"rnCall createhtml(url,filename,path)rnrnrn注:好像是fso不能生成utf-8编码,只能生成unicode,需要改成adodb.stream,但不知道怎么改,呵呵,大家会的帮我下哈 论坛

没有更多推荐了,返回首页