File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change 5
5
#include " v8-inspector.h"
6
6
#include " util-inl.h"
7
7
8
- #include < unicode/unistr.h>
9
-
10
8
#include < functional>
11
9
#include < memory>
12
10
@@ -289,10 +287,20 @@ Deletable* MainThreadInterface::GetObjectIfExists(int id) {
289
287
}
290
288
291
289
std::unique_ptr<StringBuffer> Utf8ToStringView (const std::string& message) {
292
- icu::UnicodeString utf16 = icu::UnicodeString::fromUTF8 (
293
- icu::StringPiece (message.data (), message.length ()));
294
- StringView view (reinterpret_cast <const uint16_t *>(utf16.getBuffer ()),
295
- utf16.length ());
290
+ v8::Isolate* isolate = v8::Isolate::TryGetCurrent ();
291
+ CHECK_NOT_NULL (isolate);
292
+
293
+ v8::Local<v8::String> myString =
294
+ v8::String::NewFromUtf8 (isolate,
295
+ message.data (),
296
+ v8::NewStringType::kNormal ,
297
+ message.length ()).ToLocalChecked ();
298
+
299
+ // Length()+1 to account for null terminator
300
+ auto buffer = std::make_unique<uint16_t []>(myString->Length ()+1 );
301
+ myString->Write (isolate, buffer.get ());
302
+ StringView view (buffer.get (), myString->Length ());
303
+
296
304
return StringBuffer::create (view);
297
305
}
298
306
You can’t perform that action at this time.
0 commit comments