我的平台是Unicode环境,字符集是Unicode字符集。用CInternetSession获取网页时,strGetSentence取出来的值全是乱码?CString strHttpName=_T("http://www.qyjz.net/AutoUpdate.asp?action=Auto"); // 需要提交数据的页面
    CString uFlag = _T("UpdateFlag");
    CString strFormData = uFlag;        // 需要提交的数据
    //AfxMessageBox(strFormData);    CInternetSession sess;
    CHttpFile* fileGet;
    CString strHeaders = _T("Content-Type: application/x-www-form-urlencoded"); // 请求头    try
    {
        fileGet=(CHttpFile*)sess.OpenURL(strHttpName);//打开文件
    }
    catch(CException* e)
    {
        fileGet = 0;
        throw;
    }    CString strSentence, strGetSentence = _T("");
    if(fileGet)
    {
        DWORD dwStatus;
        DWORD dwBuffLen = sizeof(dwStatus);
        BOOL bSuccess = fileGet->QueryInfo(HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, &dwStatus, &dwBuffLen);
        if( bSuccess && dwStatus>= 200 &&dwStatus<300 )
        { 
            //写入用户的Cookie信息
            BOOL result = fileGet->SendRequest(strHeaders, (LPVOID)(LPCTSTR)strFormData, strFormData.GetLength()* 2 +2);
            //////////////////////////////////////////////////////////////////////////////////////////////////////
            while(fileGet->ReadString(strSentence))    // 读取提交数据后的返回结果
            {
                strGetSentence = strGetSentence + strSentence + char(13) + char(10);

解决方案 »

  1.   

    需要做转换。ANSI 到 Unicode的转换。MultibyteToWideChar()/WideCharToMultibyte()
      

  2.   

    用_bstr_t 类,直接进行字符转换。
    #include <comdef.h>char * 转 wchar_t*
    char chars[500];
    _bstr_t bstr = chars;wchar_t* 转 char *
    CString str1 =  bstr;
      

  3.   

    http://download.csdn.net/user/developCpp
    获取远程HTML网页内容
      

  4.   

    用这个获取网页内容:使用糖果专业下载组件http://www.languangav.com/soft/product_down.htm