' UTF-8 (BOMなし) + LF
' いったん UTF-8(BOM付き)でStreamに書く
Set stmText = CreateObject("ADODB.Stream")
With stmText
.Type = 2
.Charset = "utf-8"
.Open
.WriteText outText, 0
.Flush
.Position = 0
.Type = 1 ' バイナリに切替
If .Size >= 3 Then .Position = 3 ' BOM(3バイト)をスキップ
End With
' 出力(バイナリ)
Set stmOut = CreateObject("ADODB.Stream")
With stmOut
.Type = 1
.Open
remain = stmText.Size - stmText.Position
If remain > 0 Then
bytes = stmText.Read(remain) ' Variant(Byte())
.Write bytes
End If
.SaveToFile filePath, 2
.Close
End With
stmText.Close
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme