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());
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());