$string = Encode::decode_utf($string); # or utf8::decode($string) if !utf8::is_utf8($string) and utf8::valid($string); ...