CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Threaded View

  1. #1
    Join Date
    Feb 2005
    Posts
    64

    Conversion Problem In Multi Byte to Wide Char

    Hi, I am working on a Unicode Conversion Module and facing this problem..

    I have define
    typedef basic_string<TCHAR> tstring;

    tstring strFirstMsg;
    tstring strSecondMsg;

    these two string contains the value which I took, from the input RTF String.
    these 2 strings some value in a lang. say chinese..
    Now I have to calculate its Unicode Equavalant..

    For this I used

    wchar_t szUnicodeBuffer[200];
    strTempUniCode.assign(strFirstMsg);
    strTempUniCode.append(strSecondMsg);

    int iWriteByte = 0;

    iWriteByte = MultiByteToWideChar(nCodePage, MB_COMPOSITE, strTempUniCode,strTempUniCode.length(),szUnicodeBuffer, 100);

    It gives error
    error C2664: 'MultiByteToWideChar' : cannot convert parameter 3 from 'class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned s
    hort> >' to 'const char *'

    after this error Itried like this

    iWriteByte = MultiByteToWideChar(nCodePage, MB_COMPOSITE, (const char*)strTempUniCode.c_str(),strTempUniCode.length(),szUnicodeBuffer, 100);

    In this case error was removed, but the output was not correct.

    I can NOT USE MFC.

    can u suggest what I should do...

    Regs
    Last edited by developerid; December 21st, 2005 at 08:36 AM. Reason: Title was editited.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured