如果使用CHttpFile的ReadString方法读取Unicode编码的网页,结果是读出的数据不正确,感觉是ReadString方法在Unicode下实现错误,因此只能使用Read方法。
const int size = 1024;
byte pByte[size];
SecureZeroMemory(pByte,size);
int count = 0;
vector<byte> vecByte;
CString strUpdateInfo;
while( ( count = pFile->Read(pByte,size) ) > 0 )
{
for(int i = 0; i < count; ++i)
{
vecByte.push_back(pByte[i]);
}
SecureZeroMemory(pByte,size);
if( count < size )
break;
}
if( vecByte.size() > 0 )
{
byte * pB = new byte[vecByte.size()];
copy(vecByte.begin(),vecByte.end(),pB);
TCHAR * pChr = (TCHAR*)pB;
strUpdateInfo = pChr;
delete [] pB;
}
else
{
strUpdateInfo = _T("");
}