UTF8 的string 转 UTF16 的 wstring
std::wstring Utf8ToUtf16(const std::string& utf8Str) {
// 获取 UTF-16 字符串所需的缓冲区大小
int wstrLength = MultiByteToWideChar(CP_UTF8, 0, utf8Str.c_str(), -1, NULL, 0);
if (wstrLength == 0) {
// 处理错误
return L"";
}
// 分配缓冲区并执行转换
std::wstring utf16Str(wstrLength, L'\0');
MultiByteToWideChar(CP_UTF8, 0, utf8Str.c_str(), -1, &utf16Str[0], wstrLength);
return utf16Str;
}
char* AnsiToUtf8(const char* ansiStr) {
// 计算需要的缓冲区大小
int utf8Size = MultiByteToWideChar(CP_ACP, 0, ansiStr, -1, NULL, 0);
wchar_t* utf16Str = (wchar