I am trying to write a Unicode file (UCS-2 Little Endian) in Perl on Windows, for example.
open my $f, ">$fName" or die "can't write $fName\n";
binmode $f, ':raw:encoding(UCS-2LE)';
print $f, "ohai\ni can haz unicodez?\nkthxbye\n";
close $f;
This basically works, except that I no longer receive the automatic translation of LF → CR / LF in the output that I get in plain text files. (Output files have only LF). If I do not specify: raw or add: crlf in the binmode call, then the output file is garbled. I tried reordering the "directives" (that is: coding to: raw) and cannot make it work. The same problem exists for reading.
source
share