#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <Windows.h>
using namespace std;
int main()
{
chars[] = "%E4%B8%AD%E5%9B%BD%E9%93%B6%E8%A1%8C%E6%AD%A6%E6%B1%89%E5%B8%82%E9%87%91%E8%9E%8D%E6%B8%AF%E9%93%B6%E8%A1%8C";
intlen = strlen(s);
char*temps = new char[len+1];
temps[len]= '\0';
inttemps_pos = 0;
//去掉%号
for(int i = 0;i<len;++i)
{
if(s[i] != '%')
{
temps[temps_pos]= s[i];
temps_pos++;
}
}
temps[temps_pos]= '\0';
cout<<temps<<endl;
inttemps_len = strlen(temps);
intUTF8len = temps_len/2;
char*UTF8str = new char[UTF8len+1];
UTF8str[UTF8len]= '\0';
//把字符转换成数字,得到真实的UTF8串
for(int i = 0;i<UTF8len*2;)
{
charconvert[3] = {0};
convert[0]= temps[i++];
convert[1]= temps[i++];
char*end;
inttempint = strtol(convert,&end,16);
UTF8str[i/2-1]= tempint;
}
//UTF8转换到UTF16
intwcslen = ::MultiByteToWideChar(CP_UTF8,NULL,UTF8str,UTF8len,NULL,0);
wchar_t*wszString = new wchar_t[wcslen + 1];
::MultiByteToWideChar(CP_UTF8,NULL,UTF8str,UTF8len,wszString,wcslen);
wszString[wcslen]= L'\0';
//设置区域std::wcout.imbue(std::locale("CHS"));
wcout<<wszString<<endl;
delete[]temps;
delete[]UTF8str;
delete[]wszString;
}