Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Remove BOM ?

by graff (Chancellor)
on Nov 19, 2008 at 06:31 UTC ( #724486=note: print w/replies, xml ) Need Help??

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:
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.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)

Replies are listed 'Best First'.
Re^2: Remove BOM ?
by marct22 (Initiate) on Oct 01, 2012 at 20:30 UTC
    Warning about that tr command, it can strip out more than just the BOM. I've seen it strip out some binary characters in an AssemblyInfo.cs file for a copyright symbol. I don't have a fix (yet), so I figured I'd at least warn!
Re^2: Remove BOM ?
by Anonymous Monk on Jun 03, 2012 at 20:31 UTC
    you can also edit the file that contains the BOM - using vi, and type :set nobomb then :wq (to save and exit) done !

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://724486]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2018-02-25 21:55 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (315 votes). Check out past polls.