I'm writing out a CSV file using Perl. The data going into the CSV contains Unicode characters. I'm using the following to write the CSV out:
open(my $fh, ">:utf8", "rpt-".$datestring.".csv")
or die "cannot open < rpt.csv: $!";
The characters are being written correctly inside the file but it doesn't appear to be including the UTF8 Byte Order Mark. This throws off my users, when they try to open the file in Excel. Is there a way to force the Byte Order Mark to be written?
I attempted it the following way:
print $fh "\x{EFBBBF};
I ended up with gibberish at the top of the file.