CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2010

    How do I pass non-english characters from char* to whcar_t* on English OS

    Code Snippet:


    int Convertchar_wchar(char* pData, int pDataLength)
    wchar_t wcsQuery[4096*2 + 2];
    memcpy((void*)wcsQuery, pData, pDataLength)
    wcout << wcsQuery << endl;

    I am trying to execute the code for multilingual support. Hence I need to handle non-english languages on English OS(here Win2K3). Now the problem is when I pass any non english characters(I have tried with Japanese) instead of passing the non-english characters it is converting it to ?????. I have confirmed its not display problem but when memcpy is called the value inside is getting changed. The value being passed through char* pData is in the form of UNICODE value, still it is converting into wrong values.

    Can some one help me to understand why memcpy is converting the value? Does memcpy internally uses default code page value? How can I pass the correct value to the wide char pointer?

    I have already tried wcscpy, RtlCopyMemory. I am not sure what Code Page to pass if MultiByteToWideChar is used such that it will support all the languages.

    Waiting for some input ASAP.


  2. #2
    Join Date
    Jul 2002

    Re: How do I pass non-english characters from char* to whcar_t* on English OS

    You cannot use copy function since every byte must be converted to two bytes. Use MultiByteToWideChar and select code page according to the language of converted text.

Tags for this Thread

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

By using this site, you agree to the Privacy Policy