I would like to be able to test a string to see if it contains non-ascii characters.
At the moment I'm using a negated character class of the hex range as below. Are there any better ways of doing the test?
sub ascii_test{
my $string = shift;
if ($string =~ /[^\x00-\x7f]/){
return "[$string] contains non ascii characters";
}
else{
return "[$string] is all ascii";
}
}