Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2016-10-26 12:06 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (340 votes). Check out past polls.