int WriteUtf8(char* buffer, int length = -1) const;
The documentation says the return value is the number of characters:
* \return The number of characters copied to the buffer
* excluding the NULL terminator.
but a quick look at the source code and tests reveal that WriteUtf8
actually returns the number of bytes written (correct me if I'm
wrong). I need to get a handle on where the writing terminated in
order to continue on the next buffer. As far as I can see this is
impossible with the current interface.
If this function returned the number of characters, I could then do
var rest = string.slice(charsWritten);
so getting the rest of the string is okay, but then I won't know how
many bytes were written in the original WriteUtf8. I couldn't assume
that `capacity` bytes were written because there might be a character
boundary...
Best would be if the function was changed to return both the bytes and
characters written:
int WriteUtf8(char* buffer, int length, int *charsWritten);
Would V8 accept a patch to change this?