22 int size = WideCharToMultiByte(CP_UTF8, 0, wstr.data(), (
int)wstr.size(), NULL, 0, NULL, NULL);
23 std::string rv(size, 0);
24 WideCharToMultiByte(CP_UTF8, 0, wstr.data(), (
int)wstr.size(), rv.data(), size, NULL, NULL);
37 return std::wstring();
38 int size = MultiByteToWideChar(CP_UTF8, 0, str.data(), (
int)str.size(), NULL, 0);
39 std::wstring rv(size, 0);
40 MultiByteToWideChar(CP_UTF8, 0, str.data(), (
int)str.size(), rv.data(), size);
55 if (errorMessageID == 0)
60 LPSTR messageBuffer =
nullptr;
65 size_t size = FormatMessageA(
66 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
67 errorMessageID, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&messageBuffer, 0, NULL);
70 std::string message(messageBuffer, size);
73 LocalFree(messageBuffer);
74 return message.substr(0, message.find_last_of(
"\n", std::max(0ull, message.size() - 5)));