ANSI: 無格式定義; Unicode: 前兩個字節(jié)為FFFE; Unicode big endian: 前兩字節(jié)為FEFF; UTF-8: 前兩字節(jié)為EFBB;
復制代碼 代碼如下:
function checkcode(path) set objstream=server.createobject("adodb.stream") objstream.Type=1 objstream.mode=3 objstream.open objstream.Position=0 objstream.loadfromfile path bintou=objstream.read(2) If AscB(MidB(bintou,1,1))=HEF And AscB(MidB(bintou,2,1))=HBB Then checkcoder="utf-8" ElseIf AscB(MidB(bintou,1,1))=HFF And AscB(MidB(bintou,2,1))=HFE Then checkcode="unicode" Else checkcode="gb2312" End If objstream.close set objstream=nothing end function