Dear mother of god whats up with all these goddamn string types
| 130 | |
| 131 | // Dear mother of god whats up with all these goddamn string types |
| 132 | wchar_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 | |
| 148 | std::string wstring2string(std::wstring& wide_string) { |