Can you please answer this question? http://stackoverflow.com/questions/28857025/perl-open-output-file-in-same-endianess-as-input-file-utf-16be-vs-utf-16le

When Perl opens an UTF-16 encoded file,

open my $in, "< :encoding(UTF-16)", "text-utf16le.txt" or die "Error $!\n";

it automatically detects the endianess thanks Byte Order Mark.

But when I open file for writing

open my $out, "> :encoding(UTF-16)", "output.txt" or die "Error $!\n";

Perl opens it as big endian by default.

How to specify to open output file in the same endianness as input file, please?

How to get endianness/encoding from the input file handle $in? PerlIO::get_layers($in) returns among other layers encoding(UTF-16).


Thank you
Hans Ginzel

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to