|
本帖最后由 窄口牛 于 2023-2-21 07:44 编辑
- Option Explicit
- Dim sTEXT,sFILE
- sFILE = "grub.cfg"
- sTEXT = "#This is a grub2 configuration file "
- Call WriteFileUTF8_NOBOM(sFILE,sTEXT)
- WScript.Echo(sTEXT)
- Private Sub WriteFileUTF8_NOBOM(sFILE,sTEXT)
- Const adSaveCreateNotExist = 1
- Const adSaveCreateOverWrite = 2
- Const adTypeBinary = 1
- Const adTypeText = 2
- Const adModeReadWrite = 3
- Dim oUTF8Stream,oBinaryStream
- Set oUTF8Stream = CreateObject("ADODB.Stream")
- Set oBinaryStream = CreateObject("ADODB.Stream")
- oUTF8Stream.Type = adTypeText
- oUTF8Stream.Charset = "utf-8"
- oUTF8Stream.Open
- oUTF8Stream.WriteText sTEXT
- oUTF8Stream.Position = 3 ' Skip BOM
- oBinaryStream.Type = adTypeBinary
- oBinaryStream.Mode = adModeReadWrite
- oBinaryStream.Open
- oUTF8Stream.CopyTo oBinaryStream
- oUTF8Stream.Flush
- oUTF8Stream.Close
- oBinaryStream.SaveToFile sFILE, adSaveCreateOverWrite
- oBinaryStream.Flush
- oBinaryStream.Close
- Set oUTF8Stream = Nothing
- Set oBinaryStream = Nothing
- End Sub
复制代码
怎么粘到后面?用于创建cfg文件?
|
|