I'm confused about this change. It looks like what you're doing is first trying to check if the truncated buffer is valid UTF-8, and if not, just looking at the last few bytes of the buffer to see if they look like UTF-8. What I was suggesting is looking at those bytes first in order to determine the proper buffer length to provide to GetBufferAsUTF8(), so that you wouldn't get a false negative by truncating in the middle of a character.

Also, for checking those bytes, it seems like there's probably a simpler way to test them than these individual if statements - just iterate backwards until you see what looks like a leading byte, figure out if the character length it indicates goes past the end of the buffer, and if so, only check the buffer up to the byte before that leading byte.