I'm trying to read a web page via WinHTTP:
bool WinHTTPClass::QueryResponseData(std::string &query_data)
{
// Read response
DWORD dwSize, dwDownloaded = 0;
do
{
// Check for available data.
if( !WinHttpQueryDataAvailable( hRequest, &dwSize ) )
{
cout << "Error querying data : " << GetLastError() << endl;
return false;
}
// Allocate space for the buffer.
char* pszOutBuffer = new char[dwSize+1];
if( !pszOutBuffer )
{
cout << "Out of memory" << endl;
dwSize=0;
}
else
{
// Read the data.
ZeroMemory( pszOutBuffer, dwSize+1 );
if( !WinHttpReadData( hRequest, (LPVOID)pszOutBuffer,
dwSize, &dwDownloaded ) )
{
cout << "Error reading data : " << GetLastError() << endl;
return false;
}
else
{
query_data += pszOutBuffer;
}
// Free the memory allocated to the buffer.
delete [] pszOutBuffer;
}
}
while( dwSize > 0 );
return true;
}
All this works well. The confusion I am having here is that should I handle the buffer data using unicode encoding buffer instead of:
char* pszOutBuffer = new char[dwSize+1];
By such as using wchar_t
instead the web pages commonly use UTF8? What's the difference? Where am I confused?