is_utf8
tests whether the Perl utf8 flag is turned on or not. It's possible for a scalar to contain correctly formed utf-8 and not have the flag turned on. I think it's possible to deliberately turn the flag on even with malformed utf-8 too, but I'm not sure.
To check whether the scalar contains UTF-8 data, you need to check the flag, and if it is not, also try something like
eval {
my $utf8 = decode_utf8 ($scalar);
}
and then check for errors in $@
.
To check whether a non-UTF-8 scalar contains non-ASCII data, your idea $scalar =~ m/\A [[:ascii:]]* \Z/xms
looks ok.