use Unicode::String; $o_in = 'in.txt'; $o_out = 'out.txt'; # get the input data into utf16 objects open ( F, $o_in ) || die; while () { push ( @raw, utf16($_)); } close (F) || die; # get a list of hex values for the data map { push (@hexout, $_->hex) } @raw; # now create an empty utf16 object Unicode::String->stringify_as( 'utf16' ); my $outo = Unicode::String->new(); # and define its hex values $outo->hex ( join '', @hexout); # dump the hex values open ( F, ">$o_out" ) || die; print F $outo; close (F) || die;