最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
检测文件编码的asp代码
时间:2022-06-29 14:25:42 编辑:袖梨 来源:一聚教程网
ansi的本地编码,都是各国自己定义的,没有固定的文件头格式,在大陆中文操作系统下,是可读的gb2312,在其他语言的系统下,就是乱码,所以这部分没必要再详细区分。
ansi:无格式定义
unicode:前两个字节为fffe
unicode big endian:前两字节为feff
utf-8:前两字节为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
原理:用stream对象预读文件的头两个字节,分析判断出utf-8、unicode、ansi(简体中文操作系统,即gb2312)编码。
相关文章
- 《复体重剪版》游戏攻略 简述+配置+下载 05-17
- 《夜族崛起》无情铁制武器图纸获取攻略 05-17
- 《哈迪斯2》隐藏6个金色信物解锁方法 05-17
- 《夜族崛起》解锁书房科技方法 05-17
- 《鲻鱼狂杰克》成就达成条件一览 05-17
- 《庄园领主》羊购买位置 05-17