Click here to Skip to main content
14,869,843 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
In my VC++ project (that is set 'Use Unicode Character Set' for Character Set):
I get a struct from a C# dll that is registered as .tlb .
In this struct , I have some string members.
I have problem to use this strings.

MY_InterfacePtr Myi(__uuidof(MY_Class));
InfoSTC info;
CString str = L"parameter";
Myi->GetInfo(str.AllocSysString(), &info);
CString sname = CString(info.LastName);   //--- sname = 'äÇÏÑí'
string sFamily = info.LastName;           // sFamoly is correct


The info.LastName has persian characters. but sname isn't correct.
I Want use strings in unicode case and in CString objects.

how do I convert info.LastName and assign it in CString ?
Posted
Comments
Richard MacCutchan 23-May-15 13:00pm
   
Exactly as shown; assuming that info.LastName points to an array of Unicode characters, with a null terminator. I suspect the "problem" is not the content, but the display of the content. If it contains Persian characters then you need to use a Persian font to display it correctly.
Zon-cpp 24-May-15 0:23am
   
I checked value of sname and sFamily and info.LastName in Debug Mode and watch window. it dosen't need to choose font and should show string correctly.
Although sFamily has Persian characters with correct value.
KarstenK 24-May-15 4:56am
   
Check if all is in the C# dll is fine. Maybe a bug is already in that code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900