use strict; use warnings; use feature 'say'; use autodie; $, = ' '; { open my $f, '>:raw:encoding(UTF-16LE):crlf', 'test'; say $f 123; } { # 1 "pure binary slurp" open my $f, '<:raw', 'test'; undef local $/; say PerlIO::get_layers( $f ); say unpack '(H2)*', <$f>; } { # 2 OP's case open my $f, '<:encoding(UTF-16LE)', 'test'; say PerlIO::get_layers( $f ); say unpack '(H2)*', <$f>; } { # 3 correct open my $f, '<:raw:encoding(UTF-16LE):crlf', 'test'; say PerlIO::get_layers( $f ); say unpack '(H2)*', <$f>; } { # 4 correct open my $f, '<', 'test'; binmode $f, ':raw:encoding(UTF-16LE):crlf'; say PerlIO::get_layers( $f ); say unpack '(H2)*', <$f>; } { # 5 same as #2 open my $f, '<', 'test'; binmode $f, ':encoding(UTF-16LE)'; say PerlIO::get_layers( $f ); say unpack '(H2)*', <$f>; } __END__ unix crlf 31 00 32 00 33 00 0d 00 0a 00 unix crlf encoding(UTF-16LE) utf8 31 32 33 0d 0a unix crlf encoding(UTF-16LE) utf8 crlf utf8 31 32 33 0a unix crlf encoding(UTF-16LE) utf8 crlf utf8 31 32 33 0a unix crlf encoding(UTF-16LE) utf8 31 32 33 0d 0a