http://www.perlmonks.org?node_id=724486


in reply to Remove BOM ?

One of my co-workers (a vi user) happened to point out to me that he was seeing the BOM as a sequence of 3 bytes, displayed as hex digit strings like this:
\xef\xbb\xbf
In any case, the safest, surest, easiest way to remove the BOM (IMHO) is a perl one-liner:
perl -CD -pe 'tr/\x{feff}//d' file.bom > file.nobom

UPDATE: Just for grins, I tried vi on my macosx and also on a freebsd box (same as my co-worker used), On the mac, the BOM was not visible, and I couldn't seem to position the cursor or issue a basic "delete" command in any way that could affect the BOM itself. On freebsd (where it appeared as three hex byte codes), this sequence of three keystrokes got rid of it: "3d." (YMMV)