Wednesday, April 24, 2013

jni jnienv GetStringLength example c c++ java


GetStringLength


jsize GetStringLength(JNIEnv *env, jstring string);

Returns the length (the count of Unicode characters) of a Java string.
LINKAGE:
Index 164 in the JNIEnv interface function table.
PARAMETERS of GetStringLength

env: the JNI interface pointer.

string: a Java string object.

RETURNS of GetStringLength

Returns the length of the Java string.
Example of GetStringLength
const wchar_t * utf16 = (wchar_t *)env->GetStringChars(bytes, NULL);
size_t length = (size_t)env->GetStringLength(bytes);        
...
env->ReleaseStringChars(bytes, (jchar *)utf16);