ASP去除文件的UTF-8格式签名

  • 文章来源:LG工作室
  • 发布时间:2017-04-12 18:02:59
  • 责任编辑:lg2lg5
导读:'***函数名:RemoveUTF8Bom'***函数说明:去除文件的UTF-8格式签名'***参数:sFilePath:需清除文件的绝对路径'***返回值:布。
'***函数名  : RemoveUTF8Bom
'***函数说明: 去除文件的UTF-8格式签名
'***参数    : sFilePath: 需清除文件的绝对路径
'***返回值  : 布尔值(成功返回True,否则返回False)
Public Function RemoveUTF8Bom(sFilePath)
    Dim oStream, oDom, oDomFile, objStream

    Set oStream = Server.CreateObject("ADODB.Stream")
    With oStream
        .Type = 1
        .Open()
        .LoadFromFile sFilePath
    End With

    Set oDom = Server.CreateObject("Microsoft.XMLDOM")
    Set oDomFile = oDom.CreateElement("file")
    With oDomFile
        .DataType = "bin.base64"
        .NodeTypedValue = oStream.Read(3)
    End With

    If oDomFile.Text = "77u/" Then
        oStream.Position = 3
        Set objStream = Server.CreateObject("ADODB.Stream")
        With objStream
            .Mode = 3
            .Type = 1
            .Open()
        End With
        oStream.CopyTo(objStream)
        objStream.SaveToFile sFilePath, 2
    End If

    Set oStream = Nothing
    Set objStream = Nothing
    Set oDomFile = Nothing
    Set oDom = Nothing

    '函数返回值
    If Err Then
        RemoveUTF8Bom = False
    Else
        RemoveUTF8Bom = True
    End If
End Function
建站套餐
联系我们
客户案例