Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
//

#include <v8_inspector/src/inspector/utils/v8-inspector-common.h>
#include <codecvt>
#include <locale>
#include <ArgConverter.h>
#include <NativeScriptAssert.h>

Expand Down Expand Up @@ -39,6 +41,16 @@ protocol::DispatchResponse Common::protocolCommandNotSupportedDispatchResponse()
return protocol::DispatchResponse::Error(s_notImplemented);
}

std::vector<uint16_t> Common::toVector(const std::string &value) {
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
std::u16string valueu16 = convert.from_bytes(value);

const uint16_t *begin = reinterpret_cast<uint16_t const *>(valueu16.data());
const uint16_t *end = reinterpret_cast<uint16_t const *>(valueu16.data() + valueu16.size());
std::vector<uint16_t> vector(begin, end);
return vector;
}

const String16 Common::s_notImplemented = "Protocol command not supported.";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class Common {

static protocol::DispatchResponse protocolCommandNotSupportedDispatchResponse();

static std::vector<uint16_t> toVector(const std::string& value);

private:
static const String16 s_notImplemented;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ void V8LogAgentImpl::EntryAdded(const std::string& text, std::string verbosityLe
auto nano = std::chrono::time_point_cast<std::chrono::milliseconds>(std::chrono::system_clock::now());
double timestamp = nano.time_since_epoch().count();

auto textString16 = String16(text.data());
auto vector = utils::Common::toVector(text);
auto textString16 = String16(vector.data(), vector.size());

auto logEntry = protocol::Log::LogEntry::create()
.setSource(protocol::Log::LogEntry::SourceEnum::Javascript)
Expand Down