I try to jstring->char->wchar_t
char* js2c(JNIEnv* env, jstring jstr) { char* rtn = NULL; jclass clsstring = env->FindClass("java/lang/String"); jstring strencode = env->NewStringUTF("utf-8"); jmethodID mid = env->GetMethodID(clsstring, "getBytes", "(Ljava/lang/String;)[B"); jbyteArray barr = (jbyteArray)env->CallObjectMethod(jstr, mid, strencode); jsize alen = env->GetArrayLength(barr); jbyte* ba = env->GetByteArrayElements(barr, JNI_FALSE); if (alen > 0) { rtn = (char*)malloc(alen + 1); memcpy(rtn, ba, alen); rtn[alen] = 0; } env->ReleaseByteArrayElements(barr, ba, 0); return rtn; } jstring c2js(JNIEnv* env, const char* str) { jstring rtn = 0; int slen = strlen(str); unsigned short * buffer = 0; if (slen == 0) rtn = (env)->NewStringUTF(str); else { int length = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)str, slen, NULL, 0); buffer = (unsigned short *)malloc(length * 2 + 1); if (MultiByteToWideChar(CP_ACP, 0, (LPCSTR)str, slen, (LPWSTR)buffer, length) > 0) rtn = (env)->NewString((jchar*)buffer, length); free(buffer); } return rtn; } jstring w2js(JNIEnv *env, wchar_t *src) { size_t len = wcslen(src) + 1; size_t converted = 0; char *dest; dest = (char*)malloc(len * sizeof(char)); wcstombs_s(&converted, dest, len, src, _TRUNCATE); jstring dst = c2js(env, dest); return dst; } wchar_t *js2w(JNIEnv *env, jstring src) { char *dest = js2c(env, src); size_t len = strlen(dest) + 1; size_t converted = 0; wchar_t *dst; dst = (wchar_t*)malloc(len * sizeof(wchar_t)); mbstowcs_s(&converted, dst, len, dest, _TRUNCATE); return dst; }