JNI編程中數據類型CString To jstring 轉換
<PRE style="BACKGROUND-COLOR: #c5c5c5; FONT-WEIGHT: bold" class=java name="code">jstring CStringTojstring(JNIEnv m_penv,CString convert) { jstring retjstring; jchar dummystring[MAX_RESULT_INFO]; jsize iLoop; jsize jlength = convert.GetLength(); // First copy the character to a unicode form for (iLoop = 0; iLoop < jlength; iLoop++) dummystring[iLoop] = (jchar) convert.GetAt(iLoop); // I commented the following part because NewString takes the length to be converted // and it doesn't look to the excess string / // Fill the rest of the string with nulls for (jLoop = iLoop; jLoop < MAX_RESULT_INFO; jLoop++) dummystring[iLoop] = (jchar) ""; */ retjstring = m_penv->NewString(dummystring, jlength); return retjstring; } </PRE>
本文由用戶 lyz 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!