use warnings; use strict; use Encode qw/encode/; use open qw/:std :utf8/; use charnames ':full'; my @encodings = qw/ latin1 latin9 cp1252 UTF-8 /; my @strs = ( "\N{LATIN SMALL LETTER E WITH ACUTE}", "\N{LATIN SMALL LIGATURE OE}", "\N{LATIN CAPITAL LETTER Y WITH DIAERESIS}", "Y\N{COMBINING DIAERESIS}", # Unicode only "e\N{COMBINING ACUTE ACCENT}", # Unicode only ); for my $str (@strs) { print "--- \"$str\" ---\n"; for my $encoding (@encodings) { my $bytes = eval {encode($encoding,"$str",Encode::FB_CROAK)}; my $out = !$bytes ? "N/A" : join( ' ', map { sprintf "%02X", ord } split //, $bytes); print "$encoding: $out\n"; } }