perl -pe' BEGIN { binmode STDIN, ":raw:perlio:encoding(UTF-16le)"; binmode STDOUT, ":raw:perlio:encoding(UTF-8)"; } ' < file.xml > file.utf8.xml