in reply to Re: Don't want BOM in output file
in thread Don't want BOM in output file
For reading input, using ":encoding(utf8)" instead of bare ":utf8" is strongly recommended.
While this is correct (for security reasons), it's unlikely to help with the OP's (presumed) problem of getting rid of a BOM in the input data. In other words, :encoding(utf8) (just like :utf8) does not filter out the BOM:
my $file = "somefile.utf8"; # create a UTF-8 encoded test file, explicitly adding a BOM open my $out, ">:utf8", $file or die $!; print $out "\x{feff}foo bär"; close $out; # read it back in open my $in, "<:encoding(utf8)", $file or die $!; $_ = <$in>; use Devel::Peek; Dump $_;
SV = PV(0x793cd0) at 0x7c53e0 REFCNT = 1 FLAGS = (POK,pPOK,UTF8) PV = 0x7c9088 "\357\273\277foo b\303\244r"\0 [UTF8 "\x{feff}foo b\x{ +e4}r"] CUR = 11 ^^^^ LEN = 80
|
|---|