<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[静怡家园]]></title> 
<link>http://www.zhanghaijun.com/index.php</link> 
<description><![CDATA[书山有路勤为径，学海无涯苦作舟！]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[静怡家园]]></copyright>
<item>
<link>http://www.zhanghaijun.com/post//</link>
<title><![CDATA[asp检测文件编码]]></title> 
<author>碟舞飞扬 &lt;webmaster@zhanghaijun.com&gt;</author>
<category><![CDATA[Web开发]]></category>
<pubDate>Wed, 20 Dec 2006 13:51:58 +0000</pubDate> 
<guid>http://www.zhanghaijun.com/post//</guid> 
<description>
<![CDATA[ 
	最近，在搞这个东西，网上也找不到asp相关的，如果有人很早弄出来了，也不要笑话偶；费了好久，总算搞定；<br/><br/>原理：用stream对象预读文件的头两个字节,分析判断出utf-8，unicode，ANSI(简体中文操作系统，即gb2312)编码<br/><br/>相关资料：<br/><br/><br/>ANSI：　　　　　　　　无格式定义；<br/>Unicode： 　　　　　　 前两个字节为FFFE；<br/>Unicode big endian：　&nbsp;&nbsp;前两字节为FEFF；　<br/>UTF-8：　 　　　　　　 前两字节为EFBB；<br/><br/>function checkcode(path)<br/>set objstream=server.createobject("adodb.stream")<br/>objstream.Type=1<br/>objstream.mode=3<br/>objstream.open<br/>objstream.Position=0<br/>objstream.loadfromfile path<br/>bintou=objstream.read(2)<br/>If AscB(MidB(bintou,1,1))=&HEF And AscB(MidB(bintou,2,1))=&HBB Then<br/>checkcoder="utf-8"<br/>ElseIf AscB(MidB(bintou,1,1))=&HFF And AscB(MidB(bintou,2,1))=&HFE Then<br/>checkcode="unicode"<br/>Else<br/>checkcode="gb2312"<br/>End If<br/>objstream.close<br/>set objstream=nothing<br/>end function<br/>补充：<br/><br/>谢小雨提醒，先前的简直是胡扯；ANSI的本地编码，都是各国自己定义的，没有固定的文件头格式，在大陆中文操作系统下，是可读的gb2312，在其他语言的系统下，就是乱码，所以这部分没必要再详细区分<br/>得到文件编码，stream流就能按照需要的编码打开，就不会乱码了
]]>
</description>
</item><item>
<link>http://www.zhanghaijun.com/post//#blogcomment</link>
<title><![CDATA[[评论] asp检测文件编码]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.zhanghaijun.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>