#7 utf8_is_valid passes string ending in incomplete character

open
nobody
5
2014-08-16
2012-07-25
Mark Bourne
No

utf8_is_valid("\xE2\x82\xAC\xE2\x82") returns TRUE. However, this ends with an incomplete character "\xE2\x82", so should return FALSE.

I believe adding the following after the main for loop, just before the final "return TRUE" should fix this:
if (0 != $mState)
{
// String ends with an incomplete character
return FALSE;
}

Discussion