#include #include "Util.h" bool isError(const HRESULT result, const std::stringstream message) { if (FAILED(result)) { std::cout << message.str() << std::hex << result << std::endl; return true; } return false; } bool isError(const HRESULT result, const char* message) { return isError(result, std::stringstream(message)); } std::string utf8Encode(const std::wstring& wstr) { if (wstr.empty()) { return std::string(); } int sizeNeeded = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, NULL, 0, NULL, NULL); std::string resultString(sizeNeeded, 0); WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, &resultString[0], sizeNeeded, NULL, NULL); return resultString; }