binmode STDOUT, ':utf8'; my $strA = "Bob\x{B4}s files"; use Encode; my $strB = Encode::decode_utf8("Bob\xC2\xB4s files"); say "strA is $strA"; say "strA is $strB"; say "strings are " . (($strA eq $strB) ? "eq" : "not eq"); say "strA flag is: ".Encode::is_utf8($strA); say "strB flag is: ".Encode::is_utf8($strB); #### if (!Encode::is_utf8($str) && $str =~ m/\x80-\xff/) { $str = Encode::encode_utf8($str); # Get utf8 byte seq Encode::_utf8_on($str); # and flip the flag }