关于adodb.stream.LoadFromFile -1参数随机报错的解决办法

bug原因是奇妙的utf两字节标识符.解决办法如下

var oStream = new ActiveXObject("adodb" + ".stream");
oStream.Open();
oStream.LoadFromFile(map_path);
oStream.Charset = "utf-8";
oStream.Position = 0;
var inputdata = "";
var size=parseInt(oStream.Size);
try {
    inputdata = oStream.ReadText();
} catch (error) {
    alert("now running on debug mode,backup to avoid unknown result");
    for(var offset=0;offset<10;offset++){
        try {
            oStream.Position = offset;
            inputdata = oStream.ReadText(size-offset);
            break;
        } catch (error) {
            
        }
    }
}
oStream.Close();

发表评论

电子邮件地址不会被公开。 必填项已用*标注