http://qs321.pair.com?node_id=823228


in reply to PerlIO: crlf layer on Windows interfering with UCS-2 unicode

Note that your proposed solution disables buffering. Replace

open my $fh, ">:raw:encoding(ucs-2le):crlf:utf8", $qfn

with

open my $fh, ">:raw:perlio:encoding(ucs-2le):crlf:utf8", $qfn

to support buffering.

Also, there doesn't appear to be a need to specify :utf8, so all you need is

open my $fh, ">:raw:perlio:encoding(ucs-2le):crlf", $qfn