MCPcopy Create free account
hub / github.com/dobin/RedEdr / string2wcharAlloc

Function string2wcharAlloc

RedEdrShared/utils.cpp:132–145  ·  view source on GitHub ↗

Dear mother of god whats up with all these goddamn string types

Source from the content-addressed store, hash-verified

130
131// Dear mother of god whats up with all these goddamn string types
132wchar_t* string2wcharAlloc(const std::string& str) {
133 if (str.empty()) {
134 wchar_t* wideString = new wchar_t[1];
135 wideString[0] = L'\0';
136 return wideString;
137 }
138 int sizeNeeded = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, nullptr, 0);
139 if (sizeNeeded <= 0) {
140 return nullptr;
141 }
142 wchar_t* wideString = new wchar_t[sizeNeeded];
143 MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, wideString, sizeNeeded);
144 return wideString;
145}
146
147
148std::string wstring2string(std::wstring& wide_string) {

Callers 2

TEST_CLASSFunction · 0.85
ConfigureKernelDriverFunction · 0.85

Calls 1

emptyMethod · 0.80

Tested by 1

TEST_CLASSFunction · 0.68