CString CSocketClientDlg::GotFile(CString filename)
{
CFile fileR;
CString strFile="";
if(!fileR.Open(filename,CFile::modeRead|CFile::typeBinary))
{
return strFile;
}
BYTE head[3];
fileR.Read(head,3);
if(!(head[0]==0xEF && head[1]==0xBB && head[2]==0xBF))
{
fileR.SeekToBegin();
}
ULONGLONG FileSize=fileR.GetLength();
char* pContent=(char*)calloc(FileSize+1,sizeof(char));
fileR.Read(pContent,FileSize);
fileR.Close();
int n=MultiByteToWideChar(CP_UTF8,0,pContent,FileSize+1,NULL,0);
wchar_t* pWideChar=(wchar_t*)calloc(n+1,sizeof(wchar_t));
MultiByteToWideChar(CP_UTF8,0,pContent,FileSize+1,pWideChar,n);
strFile=CString(pWideChar);
free(pContent);
free(pWideChar);
return strFile;
}