3

I'm trying to build a native node module against Node 12 and am getting errors such as:

warning: ‘static v8::Local<v8::String> v8::String::NewFromUtf8(v8::Isolate*, const char*, v8::String::NewStringType, int)’ is deprecated: Use maybe version [-Wdeprecated-declarations]

On code such as:

v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), "some string")

I understand the error, but based on the v8::String docs, I can't figure out how to specify the Maybe version... The prototypes look the same. How can I use the Maybe version of this function?

logidelic
  • 1,525
  • 15
  • 42
  • You'll find the answer there: https://stackoverflow.com/questions/48113427/convert-stdstring-to-v8string-and-viceversa – Dmitry Oct 18 '21 at 16:21

1 Answers1

-1
size_t size = 100;
char *CharBuff = new char[size + 1];

v8::MaybeLocal<v8::String> result = v8::String::NewFromUtf8(
    isolate, CharBuff, v8::NewStringType::kNormal, static_cast<int>(size));
Satyan
  • 1,346
  • 8
  • 15