Hi again, gmpassos :)
This is what I use: (I didn't write this myself)
# ValidUTF8 came from: http://people.netscape.com/ftang/utf8/isutf8.pl sub ValidUTF8 { local ( $utf8 ) = pop (@_); if($utf8 =~ /^(([\0-\x7F])|([\xC0-\xDF][\x80-\xBF])|([\xE0-\xE +F][\x80-\xBF][\x80-\xBF])|([\xF0-\xF7][\x80-\xBF][\x80-\xBF][\x80-\xB +F])|([\xF8-\xFB][\x80-\xBF][\x80-\xBF][\x80-\xBF][\x80-\xBF])|([\xFC- +\xFE][\x80-\xBF][\x80-\xBF][\x80-\xBF][\x80-\xBF][\x80-\xBF]))*$/) { return ! ($utf8 =~ /([\xC0-\xC1])|([\xE0][\x80-\x9F])| +([\xF0][\x80-\x8F])|([\xF8][\x80-\x87])|([\xFC][\x80-\x83])/); } else { return 0; } }
In reply to Re: How to know if a string has UTF-8?
by fglock
in thread How to know if a string has UTF-8?
by gmpassos
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |