P
Parvathy_priya
Guest
Hi,
I am calling dotNET class from C++ program using methodinfo.invoke method.Parameter for the invoke method is a string.The value of the string is in UTF-8 codepage.while printing the parameter via dotnet method it is printing ASCII charater. Data is getting lost.
c++ program:
MethodInfo *mi = NULL;
char *param="Şəçüöğ"
String *args[] = new String*[1];
args[0]= new String(param);
printf("from try %s",args[0]);
String *str=static_cast<String*>(mi->Invoke(o,args));
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace T24Unicode
{
public class UnicodeTest
{
public string GetData(string text1)
{
byte[] utf = System.Text.Encoding.UTF8.GetBytes(text1);
string s2= System.Text.Encoding.UTF8.GetString(utf);
Console.WriteLine("The value returned from .cs when writing the parameter using Console.WriteLine : "+s2);
return text1;
}
}
}
output:
The value returned from .cs when writing the parameter using Console.WriteLine : Şəçüöğ
can someone please help on this?
Continue reading...
I am calling dotNET class from C++ program using methodinfo.invoke method.Parameter for the invoke method is a string.The value of the string is in UTF-8 codepage.while printing the parameter via dotnet method it is printing ASCII charater. Data is getting lost.
c++ program:
MethodInfo *mi = NULL;
char *param="Şəçüöğ"
String *args[] = new String*[1];
args[0]= new String(param);
printf("from try %s",args[0]);
String *str=static_cast<String*>(mi->Invoke(o,args));
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace T24Unicode
{
public class UnicodeTest
{
public string GetData(string text1)
{
byte[] utf = System.Text.Encoding.UTF8.GetBytes(text1);
string s2= System.Text.Encoding.UTF8.GetString(utf);
Console.WriteLine("The value returned from .cs when writing the parameter using Console.WriteLine : "+s2);
return text1;
}
}
}
output:
The value returned from .cs when writing the parameter using Console.WriteLine : Şəçüöğ
can someone please help on this?
Continue reading...