http://www.perlmonks.org?node_id=996904


in reply to Re: Remove BOM ?
in thread Remove BOM ?

except that /g can't be right. A BOM can only appear as the first few bytes of a data stream. If there is a further BOM then most likely you've got a binary file rather than a text file.

It's not clear to me what the nulls are doing in there.

True laziness is hard work

Replies are listed 'Best First'.
Re^3: Remove BOM ?
by afoken (Chancellor) on Oct 03, 2012 at 11:14 UTC
    It's not clear to me what the nulls are doing in there.

    BOM in UTF-32 LE and BE encodings.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re^3: Remove BOM ?
by jdporter (Paladin) on Oct 02, 2012 at 20:22 UTC

    It depends. Unless all your text processing tools are UNICODE-smart, you can easily end up with a BOM at the beginning of any line, not just the first, and really they could end up anywhere, depending on what you're doing. Imagine using cat and paste on files with BOMs. In my experience (and I've had quite a bit), I almost always end up having to delete BOM-looking strings from the entire file, not just the beginning.