On Wed, Mar 16, 2016 at 9:59 PM, HungryHippo
<[email protected]> wrote:
> hi, i'm really struggling to work with Nan and conversions of C++ to V8
> types.
>
> How would i convert this format ? std::vector<uint8_t> data;
>
>
> info.GetReturnValue().Set(Nan::New<v8::String>(convertedData));
>
>
> thanks for any help :-)
if (data.empty()) {
info.GetReturnValue().SetEmptyString();
} else {
// Assumes |data| contains valid UTF-8.
const char* chars = reinterpret_cast<const char*>(&data[0]);
info.GetReturnValue().Set(Nan::New(chars, data.size()).ToLocalChecked());
}
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/CAHQurc8xp5tsgrY9U7XGf%3D7169kY0x7mJB8Di4_gX7TpH5NNWg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.