News for hackers. Stuff that matters.
Re:Type conversions from JavaScript to C++ in V8 by dkopi on Sunday April 03, 2016 @03:04PM (#11417179)
Does V8 have easy conversion between V8 classes and std classes?

converting a V8 string to an std string and back by first casting to a null terminated char array seems very cumbersome and error prone.

Re:Type conversions from JavaScript to C++ in V8 by tibiapejagala on Sunday April 03, 2016 @04:19PM (#11417455)
It would make sense to provide some.

Example problem could be that both JavaScript strings and std::string can have '\0' bytes in them. Converting them like in the post would lead to string truncation if a null byte was present somewhere in the middle of a string.

So it should be something like (error checking aside): v8::String::Utf8Value s(args[0]); std::string str(*s, s.length());