how to best way to encode all of data in input
like this
#!/usr/bin/perl
use Encode qw(all);
my $ENC_ASCII = 'ASCII';
# When all other defaults are exhausted, use UTF-8
my $result = undef;
eval{
$result = Encode::encode_utf8($text);1;
};
if($@){
}
if($result){
return $result;
}
# Something is seriously wrong if we get to here
return encode($ENC_ASCII, $text, undef);
like that
# IO layer: $handle now decodes all strings upon reading
open my $handle, '<:encoding(UTF-8)', $file;
or
binmode $handle, ':encoding(UTF-8)';