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

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:

\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)


Comment on Re: Remove BOM ?
Select or Download Code
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 ! dror.mikdash@pharmatek.co.il
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!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://724486]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2014-04-20 15:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls