PERL UTF-8
encode variable to bytes
Encode::_utf8_off $buf;
decode 100% valid utf8 data
Encode::_utf8_on $str;
If we are sure, that input data is valid utf8 string.
decode possible utf8 data
my $success = utf8::decode $buf;
The UTF-8 flag is turned on only if the source string contains multiple-byte UTF-8 characters.