UTF-8(bom-non)

Posted on 2020-02-23 23:17  wzhw2015  阅读(145)  评论(0编辑  收藏  举报

Public Sub WriteUTF_8BomNon(ByVal fileName As String, ByVal strLine As String)

Dim stream: Set stream = CreateObject("ADODB.Stream")
stream.Type = 2 ' adTypeText
stream.Charset = "UTF-8"
stream.Open
stream.writeText strLine

stream.Position = 0
stream.Type = 1 ' adTypeBinary

stream.Position = 3
Dim bin: bin = stream.Read()
stream.Close

Dim restream: Set restream = CreateObject("ADODB.Stream")
restream.Type = 1 ' dTypeBinary
restream.Open
restream.Write bin
restream.SaveToFile fileName, 2 ' force overwrite
restream.Close

End Sub

Copyright © 2024 wzhw2015
Powered by .NET 9.0 on Kubernetes