#!/usr/bin/perl use strict; use warnings; use Encode; use Encode::Guess; my $data='pâté'; #my $data='pate'; my $enc = guess_encoding($data, qw/ascii utf8 utf16 iso-8859-1/); ref($enc) or die "Can't guess: $enc"; # trap error this way #my $utf8 = $enc->decode($data); # or my $utf8 = decode($enc->name, $data); print $utf8,"\n\n";