function detect Unicode UTF-8 string PHP
Based upon that snippet below using preg_match() I needed something faster and less specific. That function works and is brilliant but it ...
https://iskablogs.blogspot.com/2014/04/function-detect-unicode-utf-8-string-php.html
Based upon that snippet below using
preg_match() I needed something faster and less specific. That function
works and is brilliant but it scans the entire strings and checks that
it conforms to UTF-8
function detectUTF8($string)
{
return preg_match('%(?:
[\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
|\xE0[\xA0-\xBF][\x80-\xBF] # excluding
preg_match() I needed something faster and less specific. That function
works and is brilliant but it scans the entire strings and checks that
it conforms to UTF-8
function detectUTF8($string)
{
return preg_match('%(?:
[\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
|\xE0[\xA0-\xBF][\x80-\xBF] # excluding