JNI编程中jstring 转换到CString
//jstring 转换到CString CString jstringToCString(JNIEnv *m_penv,jstring jnistr) { // We modified in this function because we founf if the length is of two chars // it add a rubish char concatenated at the end of the string CString dummyCString, retCString; jsize istringlength; jboolean isCopy = JNI_TRUE; const jchar *pChar = m_penv->GetStringChars(jnistr,&isCopy); istringlength = m_penv->GetStringLength(jnistr); dummyCString = (BSTR) pChar; retCString = dummyCString.Mid(0, istringlength); m_penv->ReleaseStringChars(jnistr,pChar); return retCString; }