#!perl
use strict;
use warnings;
open my $input_fh, '<:encoding(UTF-16LE)', 'Input.txt';
open my $output_fh, '>:encoding(UTF-16LE)', 'Output.txt';
while (my $line = <$input_fh>) {
chomp $line;
print $output_fh "$line\n";
}
####
#!perl
use strict;
use warnings;
open my $input_fh,
'<:raw:perlio:encoding(UTF-16LE):crlf', 'Input.txt';
open my $output_fh,
'>:raw:perlio:encoding(UTF-16LE):crlf', 'Output.txt';
while (my $line = <$input_fh>) {
chomp $line;
print $output_fh "$line\n";
}
##
##
#!perl
use strict;
use warnings;
use charnames qw( :full );
open my $input_fh,
'<:raw:perlio:encoding(UTF-16):crlf', 'Input.txt';
open my $output_fh,
'>:raw:perlio:encoding(UTF-16LE):crlf', 'Output.txt';
print $output_fh "\N{BYTE ORDER MARK}";
while (my $line = <$input_fh>) {
chomp $line;
print $output_fh "$line\n";
}