asp生成utf-8编码静态文件
asp生成utf-8编码的静态html文件。Scripting.filesystemobject的createTextFile只能指定为unicode,所以asp要生成utf-8编码的静态文件,需要使用adodb.stream来生成,adodb.stream可以指定任何编码。
'asp生成指定编码静态html页面过程源代码 Sub WriteToTextFile(FileUrl,byval Str,CharSet) set stm=Server.CreateObject("adodb.stream") stm.Type=2'以本模式读取 stm.mode=3 stm.charset=CharSet stm.open stm.WriteText str stm.SaveToFile Server.MapPath(FileUrl),2 '转为物理路径 stm.flush stm.Close set stm=nothing End Sub 'asp生成utf-8编码静态文件示例 WriteToTextFile "/index.html","utf-8格式的内容,如果要防止乱码注意meta要指定charset为utf-8,并且要增加codepage之类的,具体参考asp网站使用utf-8编码注意事项","utf-8"
加支付宝好友偷能量挖...
原创文章,转载请注明出处:asp生成utf-8编码静态文件