use strict; use warnings; use Encode qw( encode ); my $enc = 'iso-latin-1'; # Desired encoding my $text = chr(130); # Any char supported by iso-latin-1 and $enc utf8::downgrade(my $text_off = $text); utf8::upgrade (my $text_on = $text); # Encode text on output my $from_off = encode($enc, $text); my $from_on = encode($enc, $text); print("bytes are ", ($from_off eq $from_on ? 'same' : 'diff'), "\n");