Correctly split the buffer when handling multi-byte utf8 characters