$ LANG=ru_RU.UTF-8 perl -CS -MEncode=decode -E ' sub show { printf "is_utf8=%d, length=%d, msg=%s\n", utf8::is_utf8($_), length, $_; } $_=$!=111; show(); $_=decode("UTF-8", $_); show(); ' is_utf8=0, length=40, msg=Ð Ñоединении оÑказано is_utf8=1, length=21, msg=[here should be correct Russian "connection refused" but perlmonks's parser turn it into html entities]