use Encode::Guess, my $enc = guess_encoding($data, qw/euc-jp shiftjis 7bit-jis/); ref($enc) or die "Can't guess: $enc"; $utf8 = $enc->decode($data); # or $utf8 = decode($enc->name, $data)