zod has asked for the wisdom of the Perl Monks concerning the following question:
I want to remove a utf8 BOM from a .pl file. I can do it by using an another perl script to process the file like so:
But why can't I just do it like this in vim when editing the file itself?while ( my $line = <IN> ) { $line =~ s/^\x{FEFF}//; print OUT $line;
That doesn't match the BOM. I'm a rookie, so maybe I'm making a rookie mistake.s/^\x{FEFF}//g
Thanks, zod
UPDATE: Just for the sake of completeness if anyone wonders about this later: The BOM is not considered part of the text of the file you are editing in VIM. Vim strips the BOM when the file is opened and sets the local 'bomb' option to remember that it must be added back when writing the file. So you can't pattern match it because it isn't there while you have the file open in VIM. See here.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Remove BOM ?
by ikegami (Patriarch) on Nov 19, 2008 at 06:04 UTC | |
|
Re: Remove BOM ?
by graff (Chancellor) on Nov 19, 2008 at 06:31 UTC | |
by marct22 (Initiate) on Oct 01, 2012 at 20:30 UTC | |
by Anonymous Monk on Jun 03, 2012 at 20:31 UTC | |
|
Re: Remove BOM ?
by moritz (Cardinal) on Nov 19, 2008 at 07:39 UTC | |
|
Re: Remove BOM ?
by Gangabass (Vicar) on Nov 19, 2008 at 07:51 UTC | |
|
Re: Remove BOM ?
by davido (Cardinal) on Oct 01, 2012 at 20:49 UTC | |
by GrandFather (Saint) on Oct 02, 2012 at 20:04 UTC | |
by afoken (Chancellor) on Oct 03, 2012 at 11:14 UTC | |
by jdporter (Paladin) on Oct 02, 2012 at 20:22 UTC |