My current knowledge:
If you are trying to write text files in vbscript / asp land you have two options.
- the Scripting.FileSystemObject
- the ADODB.Stream object
Scripting.FileSystemObject does not support utf8. It will write in Ascii, or Unicode (and waste two bytes for most of your characters)
ADODB.Stream does not support appending (afaik). I can’t figure out how to make the ADODB.Stream object actually open a file and write to it when I call stream.Write. There is a SaveToFile function, but it outputs the entire stream.
If you need to write 1GB files, you would have to fill the whole 1GB into the stream before you could write it out.
Is there a special trick to get the ADODB.Stream object to link to a file on disk? I tried :
stream.Open 'URL=file:///c:\test.txt'
but that gave an error.
In this scenario, I would probably create a COM component that takes a string, and runs it through WideCharToMultiByte to convert it to UTF-8.
In case you really want to stay within VBScript, I just hacked up a very quick and very dirty UTF-8 conversion…
Just open a file with Scripting.FileSystemObject, using system default encoding. Then pass every character of the string you want to write through this function.
NOTE that the function expects a Unicode code point, so be sure to use
AscW()instead of plainAsc():