change isValidUtf8 to use iterators rather than c strings