The line CString name = col.pADsValues[x].CaseIgnoreString; works fine for English text, but returns '???' for other languages. For example if the Active directory contains any user's name in Chinese or Japanese text '邮箱' then CString name shows '???' instead of the actual unicode text.
The same code works properly in another MFC Application project but fails for this ATL dll project.
Project settings are :
Configuration Type : Dynamic Library(.dll)
Use of MFC : Use MFC in a Static Library
Use of ATL : Static Link to ATL
Character Set : Use Unicode Character Set
Cannot trace what I have been missing out. Please help.
this code would convert from UTF-8 to UTF-16. the latter is a 16-bit layer of UTF-32 called "UNICODE" by microsoft. UTF-8 is a multi-byte character set where a UNICODE character has 1 to 4 bytes and it is mightier than UTF-16 though both cover most common characters used in the word.
Sara
sarabande
col.pADsValues[x].CaseIgnoreString
i assumed that this is a byte buffer. you may have to use an intermediate char buffer if the string you got in col.pADsValues[x].CaseIgnoreString already is converted to a wide character string buffer.
byte buffer[SOME_SIZE+1] = { 0 };memcpy(buffer, your_byte_array, SOME_SIZE);// this call checks how many characters are needed for the wide char stringint wchars_num = MultiByteToWideChar( CP_UTF8 , 0 , (const char *)buffer , -1, NULL , 0 );// the next call retrieves the wide stringMultiByteToWideChar( CP_UTF8 , 0 , (const char *)buffer, -1, name.GetBuffer(wchars_num+1) , wchars_num);name.ReleaseBuffer();
Sara, thanks for the suggestion. I tried with the byte buffer but it still shows junk. I am wondering why is this not working only in ATL project when it works fine in another MFC application.
Still stuck on this. Any help would be very much appreciated.
this code would convert from UTF-8 to UTF-16. the latter is a 16-bit layer of UTF-32 called "UNICODE" by microsoft. UTF-8 is a multi-byte character set where a UNICODE character has 1 to 4 bytes and it is mightier than UTF-16 though both cover most common characters used in the word.
Sara