Skip to content

Instantly share code, notes, and snippets.

@koma5
Created February 24, 2012 09:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koma5/1899792 to your computer and use it in GitHub Desktop.
Save koma5/1899792 to your computer and use it in GitHub Desktop.
this script removes the UTF-8 BOM "" 0xEFBBBF from the beginning of a file / just drag and drop a file on this script
Option Explicit
Const UTF8_BOM = ""
Const ForReading = 1
Const ForWriting = 2
Dim fso
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
Dim f
f = WScript.Arguments.Item(0)
Dim t
t = fso.OpenTextFile(f, ForReading).ReadAll
If Left(t, 3) = UTF8_BOM Then
fso.OpenTextFile(f, ForWriting).Write (Mid(t, 4))
MsgBox "BOM deleted!"
Else
MsgBox "UTF-8-BOM not found!"
End If
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment