Closed
Description
if (!buf) {
CHECK_ARG(env, result);
*result = val.As<v8::String>()->Utf8Length();
// ex. return 11 for 'hello world'
} else {
int copied = val.As<v8::String>()->WriteUtf8(
buf, bufsize, nullptr, v8::String::REPLACE_INVALID_UTF8);
if (result != nullptr) {
*result = copied;
// ex. return 12 for 'hello world' because of the null character in the end
}
}
Maybe we should pass in the option v8::String::NO_NULL_TERMINATION or substract one from the copied? @mhdawson @aruneshchandra @jasongin
Metadata
Metadata
Assignees
Labels
No labels