in reply to CRLF not encoding into UTF-16LE correctly on ActivePerl 5.8.8
Encoding the strings manually and then outputting them with syswrite() works too:
use strict; use warnings; use 5.010; use Encode qw{encode}; my $string = "Line1\015\012Line2\015\012\015\012Line4\015\012"; my $utf16_string = encode('UTF16-LE', $string); open my $OUTPUT_FH, '>', 'data1.txt' or die "Unable to open data1.txt: $!"; syswrite $OUTPUT_FH, $utf16_string ; --hex output:-- 4C 00 69 00 6E 00 65 00 31 00 0D 00 0A 00 4C 00 69 00 6E 00 65 00 32 00 0D 00 0A 00 0D 00 0A 00 4C 00 69 00 6E 00 65 00 34 00 0D 00 0A 00
|
|---|