in reply to How do I convert text from UTF-8 to UTF-16LE in Perl

From Perl Cookbook ISBN 0596003137:

open(my $ifh, "<:encoding(ENCODING_NAME)", $filename); open(my $ofh, ">:encoding(ENCODING_NAME)", $filename);

Perl is Huffman encoded by design.

Replies are listed 'Best First'.
Re^2: How do I convert text from UTF-8 to UTF-16LE in Perl
by graff (Chancellor) on Jun 18, 2005 at 16:20 UTC
    Actually, since the input is utf8, the "more natural" way (with the "blanks" filled in) would be:
    open( my $ifh, "<:utf8", $iname) or die "$iname: $!"; open( my $ofh, ">:encoding(UTF-16LE)", $oname ) or die "$oname: $!"; print $ofh while (<$ifh>);