4 ms·
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 ar
by dkopi 11y ago
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.
- tibiapejagala 11y agoIt 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());