Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Remove BOM ?

by graff (Chancellor)
on Nov 19, 2008 at 06:31 UTC ( [id://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)

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 ! dror.mikdash@pharmatek.co.il

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-04-26 07:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found