use strict; use warnings; use Encode qw( decode _utf8_on ); use Devel::Peek; my $bytes = "\x{C2}A"; { open(my $fh, '>:raw', 'temp') or die; print $fh $bytes; } { print STDERR "_utf8_on\n"; print STDERR "--------\n"; open(my $fh, '<:raw', 'temp') or die; _utf8_on(my $chars = <$fh>); Dump($chars); } print STDERR "\n"; { print STDERR "binmode ':utf8'\n"; print STDERR "---------------\n"; open(my $fh, '<:utf8', 'temp') or die; my $chars = <$fh>; Dump($chars); } print STDERR "\n"; { print STDERR "binmode ':encoding(utf8)'\n"; print STDERR "-------------------------\n"; open(my $fh, '<:encoding(utf8)', 'temp') or die; my $chars = <$fh>; Dump($chars); } print STDERR "\n"; { print STDERR "decode 'utf8'\n"; print STDERR "-------------\n"; my $chars = decode('utf8', $bytes); Dump($chars); } print STDERR "\n"; { print STDERR "decode 'utf-8'\n"; print STDERR "--------------\n"; my $chars = decode('utf-8', $bytes); Dump($chars); } unlink 'temp';