BOM

armsys
2StarLounger
Posts: 105
Joined: 19 Apr 2010, 10:25
Location: Hong Kong

BOM

Post by armsys »

Please help me write a VBScript to insert a Byte Order Marker (BOM) into a text string/file.
Thanks.
Regards,
Armstrong

User avatar
HansV
Administrator
Posts: 78549
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: BOM

Post by HansV »

Try code like this - a BOM should be written at the beginning of the file automatically because the 3rd argument to CreateTextFile is True (specifying Unicode):

Code: Select all

Dim fso
Dim tf
Set fso = CreateObject("Scripting.FileSystemObject")
Set tf = fso.CreateTextFile("C:\MyFiles\Test.txt", True, True)
tf.WriteLine "Hello World"
tf.Close
If that does not do what you want please provide more information about what you want to accomplish.
Best wishes,
Hans

armsys
2StarLounger
Posts: 105
Joined: 19 Apr 2010, 10:25
Location: Hong Kong

Re: BOM

Post by armsys »

HansV,
Thanks for your quick help.
Regards,
Armstrong