Could we read in a fixed number of bytes (say "n"), then manually inspect the last four bytes to figure out where the end of the last valid UTF-8 character would be if it were UTF-8? (Should be easy to do since each byte tells you whether it's a leading byte or continuation byte and how long the character is from the last leading byte.) That way we could figure out the exact length to pass to the UTF-8 checking function.