use Unicode::String; my $string = "This is a test\n"; my $u = Unicode::String->new($string); # print as UCS2 print $u->ucs2;