it's probably sthg simple, here is what I tried :
Set objStream = CreateObject("ADODB.Stream")
Set objStreamNoBOM = CreateObject("ADODB.Stream")
With objStream
.Open
.Charset = "UTF-8"
.WriteText "aaaaaa"
.Position = 0
End With
With objStreamNoBOM
'.Charset = "Windows-1252" ' WORK
.Charset = "UTF-8" ' DOESN'T WORK!!
.Open
.Type = 2
.WriteText objStream.ReadText
.SaveToFile "toto.php", 2
.Close
End With
objStream.Close
if the charset is UTF-8, then there is ï» at the beginning of the file.
Any idea on how to save a file with UTF-8 and without BOM?
I knew that the Scripting File System Object's stream inserted a Byte Order Mark, but I haven't seen that with the ADODB Stream.
Or at least, not yet: I rarely use the ADODB stream object...
But I do remember putting this remark into some code a few years ago:
You can tell I was having a bad day.
Next, using prehistoric PUT commands from the days before file-handling had emerged from the primordial C:
So there's the code that actually does it:
I'm assuming that strText is actually UTF-8. I mean, we're in VBA, in Microsoft Office, and we absolutely know that this is always going to be UTF-8, even we use it in a foreign country...
...Right?
In the best of all possible worlds the Related list would contain a reference to this question which I found as the first hit for "vbscript adodb.stream bom vbscript site:stackoverflow.com".
Based on the second strategy from boost's answer:
Evidence: