I have one dll of cpp and i need to call its function which returns char*. Im using String in native Declaration but getting out put like ???? or some crap thing. I just want to knw that do i have to decode the String.i have already set my system property like System.setProperty("jna.encoding","UTF-8"); Im in big mess. Hope to get Some Positive replies from u guys. Thanks in Advance.. Cheers...!
A:
Try using a Pointer instead of String and then use the getString(long offset) method of pointer to get the string, it implicitly uses the jna.encoding if set.
Aravias
2010-04-20 21:14:51
A:
char* Return:
Pointer myFunc();
Pointer ptr = myFunc();
String str = ptr.getString(0);
str = str.substring(0, str.indexOf(0)); //Remove garbage after null char
char* Param:
void myFunc(Pointer ptr);
String str = "hello world";
Memory mem = new Memory(str.length());
memory.write(0, str.getBytes(), 0, str.length());
myFunc(mem);
Nick
2010-06-10 15:11:31