#include "Common.h" ///////////////////// convert strings std::string ConvertWideToANSI(const std::wstring& wstr) { int num_chars = WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), wstr.length(), NULL, 0, NULL, NULL); std::string str; str.resize(num_chars); WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), -1, &str[0], wstr.length(), NULL, NULL); return str; } std::wstring ConvertAnsiToWide(const std::string& str) { int num_chars = MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.length(), NULL, 0); std::wstring wstr; wstr.resize(num_chars); MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.length(), &wstr[0], num_chars); return wstr; } std::string ConvertWideToUtf8(const std::wstring& wstr) { int num_chars = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), wstr.length(), NULL, 0, NULL, NULL); std::string str; str.resize(num_chars); WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, &str[0], wstr.length(), NULL, NULL); return str; } std::wstring ConvertUtf8ToWide(const std::string& str) { int num_chars = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.length(), NULL, 0); std::wstring wstr; wstr.resize(num_chars); MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.length(), &wstr[0], num_chars); return wstr; }