//StringConvert.h
#ifndef STRINGCONVERT_H_H
#define STRINGCONVERT_H_H
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
using std::string;
using std::wstring;
wstring AsciiToUnicode(const string& str);
string AsciiToUtf8(const string& str);
string UnicodeToAscii(const wstring& wstr);
string UnicodeToUtf8(const wstring& wstr);
string Utf8ToAscii(const string& str);
wstring Utf8ToUnicode(const string& str);
#endif
//StringConvert.cpp
#include "stdafx.h"
#include "StringConvert.h"
wstring AsciiToUnicode(const string& str)
{
//得到str的字节数
int len = MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, nullptr, 0);
wchar_t * wstr = new wchar_t[sizeof(wchar_t)*len];
MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, wstr, len);
wstring destr = wstr;
delete[] wstr;
return destr;
}