MCPcopy Create free account
hub / github.com/WallBreaker2/op / wideToBytes

Function wideToBytes

libop/memory/ProcessMemory.cpp:30–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28}
29
30vector<uchar> wideToBytes(const wstring &text, UINT cp, bool nullTerminated) {
31 const int len = ::WideCharToMultiByte(cp, 0, text.c_str(), -1, nullptr, 0, nullptr, nullptr);
32 if (len <= 0)
33 return {};
34 vector<uchar> bin(static_cast<size_t>(len));
35 ::WideCharToMultiByte(cp, 0, text.c_str(), -1, reinterpret_cast<LPSTR>(bin.data()), len, nullptr, nullptr);
36 if (!nullTerminated && !bin.empty() && bin.back() == 0)
37 bin.pop_back();
38 return bin;
39}
40
41wstring decodeUnicodeBytes(const vector<uchar> &bin) {
42 if (bin.size() < sizeof(wchar_t))

Callers 1

WriteStringMethod · 0.85

Calls 2

dataMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected