I have a function in socket.dll library as below:
 __declspec(dllexport) string GetPib(const wchar_t* pib_key_chars)
 {
    wstring ws(pib_key_chars);
    std::string pib_key(ws.begin(), ws.end());
        cout << "In GetPib" << "  and pib_key in string=" << pib_key << endl;
    Pib pb;
    return std::to_string(pb.Get(phyFskTxPacket, 0));
 }
When i use "dumpbin /exports socket.dll" to check the GetPib function of socket.dll signature it returns
1    0 00011370 ?GetPib@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?
$allocator@D@2@@std@@V12@@Z = @ILT+875(?GetPib@@YA?AV?$basic_string@DU?
$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@Z) 
I am using the same signature in the C# project(WindowsFormsApp1) to call/invoke GetPib function.
Below is the C# source code to invoke GetPib function:
 namespace WindowsFormsApp1
 {
     public partial class Form1 : Form
     {
         [DllImport("socket.dll", EntryPoint = "?GetPib@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PB_W@Z", CallingConvention = CallingConvention.Cdecl)]
         public static extern string GetPib([MarshalAs(UnmanagedType.LPStr)] string pib_key);        
         public Form1()
         {
             InitializeComponent();
         }
         private void GetPib_button_Click(object sender, EventArgs e)
         {
             String str = pib_id_tbox.Text;
             pib_uvalue_tbox.Text = GetPib(str);
         }
 }
When I invoke GetPib function like GetPib(0x1004xxx4), it invokes the socket.dll's GetPib function but the value is different with special characters
str=0x10040004  tr=268697604-----> in C# file
In GetPib  and pib_key in string=h䤰„------> in C++ .dll file
How to fix this issue.
 
    