1,将UTF-8转换为html
int Utf8ToAnsi(const char *pstrUTF8, char *pstrAnsi)
{
int i = 0;
int j = 0;
char strUnicode[200] = {0};ide
i = MultiByteToWideChar(CP_UTF8, 0, pstrUTF8, -1, NULL, 0);
memset(strUnicode, 0, i);
MultiByteToWideChar(CP_UTF8, 0, pstrUTF8, -1, strUnicode, i);
j = WideCharToMultiByte(CP_ACP, 0, strUnicode, -1, NULL, 0, NULL, NULL);
WideCharToMultiByte(CP_ACP, 0, strUnicode, -1, pstrAnsi, j, NULL, NULL);
return 0;
}编码
2,其余的编码转换spa
qp::StringW Global::AnsiToUnicode(const char* buf)
{
int len = ::MultiByteToWideChar(CP_ACP, 0, buf, -1, NULL, 0);
if (len == 0) return L"";.net
std::vector unicode(len);
::MultiByteToWideChar(CP_ACP, 0, buf, -1, &unicode[0], len);3d
return &unicode[0];