Trouble converting to standard c++ types
Hi
I have a method in c++ which gets a jobjectArray from java. The array is a String[][] with unicode strings.
I parse the array and picks out the objects as jobject. I then cast the objects to jstring. If I now use GetStringChars on those jstrings, I get a jchar* which I can print.
My problem is I want the strings that I give in from the java-side converted to char*. Does anyone know how I can get that, either from my jobject, jstring or jchar? I have tried using GetStringUTFChars, but it does not give the correct output.
Here is a bit of my code, not very nice, but maybe it gives an idea of what I want.
8<8<8<8<8<8<8<
int nParameters = env->GetArrayLength(parameters);
jclass class_String = env->FindClass("java/lang/String");
for(int i = 0;i<nParameters;i++){
jobjectArray row = (jobjectArray) env->GetObjectArrayElement(parameters,i);
int rowLength = env->GetArrayLength(row);
if(rowLength!=2){
wprintf(L"Wrong length on array!");
}
jobject arg = env->GetObjectArrayElement(row,0);
if(env->IsInstanceOf(arg,class_String)){
jstring type= (jstring)arg;
jobject arg2 = env->GetObjectArrayElement(row,1);
if(env->IsInstanceOf(arg2,class_String)){
jstring value = (jstring)arg2;
wprintf(L"type: %s, value: %s\n",type,value); //output not readable
if((type == NULL)||(value==NULL)){
wprintf(L"type or value == null\n");
return;
}
const jchar* tmpCType = env->GetStringChars(type, &bValueTrue);
const jchar* tmpCValue = env->GetStringChars(value,&bValueTrue);
wprintf(L"cType: %s, cValue: %s\n",tmpCType,tmpCValue); //output readable
8<8<8<8<8<8<8<
Thnx for all input.
--Hodne

