none
CHttpFile

    Question

  • Hi,

    I have an issue. If I include wide characters (wchar_t) to the second parameter to CHttpFile::SendRequest() , the subsequent call  to CHttpFile::Read() does not succeed.

    For the wchar_t data , I use casting something as (LPVOID)(LPCTSR)

    Code is something as follows.

    CString p_strHeaders = _T("Content-Type: application/x-www-form-urlencoded\r\n\r\n");

    //.........

    m_pFile1->SendRequest(p_strHeaders,
       (LPVOID)pTotal, dwHeaderSize + dwFileSize + dwFooterSize);

    where pTotal is BYTE*

    m_pFile1->QueryInfoStatusCode(dwStatus);
    nBytesRead = m_pFile1->Read(buffer, MAXBUF - 1); 

    My requirement is to upload file containing wide character data (Japanese characters) to the server. How can I pass wide characters in the second parameters?

    Regards,

    George

    Thursday, March 10, 2011 6:23 AM

Answers

All replies

  • Well, if content type is "url encoded" then you have to url encode. Also, the web pretty much uses utf-8, not utf-16 which is implied by wchar_t.

    So you first have to convert the string to utf-8 by using something like WideCharToMultiByte with codepage = CP_UTF8 and then url encode (see http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1) the utf-8 string.

     

    Thursday, March 10, 2011 7:11 AM
    Moderator
  •  

    Hi George,

     

    I'm very interested in hearing more about your issue, did you solve your problem?

    If so please share the solution with us and mark the right answers.

    If not please let me know and I will tray to help you find further solutions.

     

    For addition, you can use GetLastError() to get the error messages.

     

    Have a nice day!

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, March 14, 2011 6:37 AM
    Moderator