ezmora
unread,Mar 22, 2011, 2:14:15 PM3/22/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to android-ndk
I am passing a String from Java to the C layer, and call
GetStringChars, in my C code, to obtain a pointer to this String.
I tried printing out this content of this pointer, but I receive
strange results.
Suppose my Java String was "zmora", my C code is:
jchar* uName = (*env)->GetStringChars(env, str, &isCopy);
__android_log_print(ANDROID_LOG_INFO, "TEST", " %s", uName );
The output is simply: "z"
However when I print out uName chars one by one I see that they
contain the correct values:
__android_log_print(ANDROID_LOG_INFO, "TEST", " %c %c %c", uName[0],
uName[1], uName[2] );
Any ideas why this is the case? Does GetStringChars return a Null
terminated buffer?