TFrmMain::ConVertUnicodeToUTF8(wchar_t* wstrIn, int vLen,wchar_t* wstrOut)
{
//TODO: Add your source code here
char hexVals[16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
int wLen=wcslen(wstrIn);
int index=0;
for(int j=0;(DWORD)j<wcslen(wstrIn);j++)
{
wchar_t c=wstrIn[j];
if (c < 0x80)
{
wstrOut[index]=c;
index++;
}
else if (c < 0x800)
{
wstrOut[index]=(0xC0 | c>>6);
index++;
wstrOut[index]=(0x80 | c & 0x3F);
index++;
}
else if (c < 0x10000)
{
BYTE num_char=(BYTE)(0xE0 | c>>12);
wstrOut[index]='%';
index++;
wstrOut[index]=hexVals[num_char/16];
index++;
wstrOut[index]=hexVals[num_char%16];
index++;
num_char=(BYTE)(0x80 | c>>6 & 0x3F);
wstrOut[index]='%';
index++;
wstrOut[index]=hexVals[num_char/16];
index++;
wstrOut[index]=hexVals[num_char%16];
index++;
num_char=(BYTE)(0x80 | c& 0x3F);
wstrOut[index]='%';
index++;
wstrOut[index]=hexVals[num_char/16];
index++;
wstrOut[index]=hexVals[num_char%16];
index++;
}
}
}