Check String for Non-ASCII Characters in Perl


if ( $string =~ /[[:^ascii:]]/ ) {
print “String contains characters that are NOT pure ASCII”;
}
else {
print “Everything is good, string/pure is valid ASCII.”;
}

E.G.: If it contains bytes > 127, it’s not valid ASCII.


You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

AddThis Social Bookmark Button

Comments are closed.