|Welcome to the Monastery|
Re: binmode file read error messageby nobull (Friar)
|on Jan 20, 2006 at 18:48 UTC||Need Help??|
The first thing in a UTF-16 data stream (of unspecified endianness) must always be the byte order mark.
Looking at the source of the Encode module the error "Unrecognised BOM" is produced when a Encode::Unicode object has no endian attribute (yet) and encounters anything other than a valid BOM.
So the above error would happen if a file that you were trying to open as UTF16 was in fact ASCII (or UTF8) and started with the two characters "%P" or indeed was, say, a PDF file.
If the Encode::Unicode object has a renewed attribute it will automatically update its own endian attribute upon seeing the initial BOM and can then subsequently process data without a BOM.
The Encode::Unicode objects used by PerlIO are supposed to have this "renewed" attribute so you should never see this message except at the start of the file.
Note that when Perl says "<FIL> line 127" in an error message this just means that the last file read operation was to read line 127 of FIL. It does not necessarily mean that is was the data that was read from that line that was actually being processed.
In particular if the error is occuring in the process of reading the first line from a file it's possible that the error message would reflect the previous read operation.
The moral of the story: don't use