diff --git a/src/windows/native/sun/windows/awt_InputTextInfor.cpp b/src/windows/native/sun/windows/awt_InputTextInfor.cpp index d904a5e9636396e4cae75ad95d5c5e317a41342d..3c26fbb95d019c62fbc646529400195cc58c9489 100644 --- a/src/windows/native/sun/windows/awt_InputTextInfor.cpp +++ b/src/windows/native/sun/windows/awt_InputTextInfor.cpp @@ -131,7 +131,7 @@ AwtInputTextInfor::GetContextData(HIMC hIMC, const LPARAM flags) { JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); if (m_cStrW > 0) { - m_jtext = MakeJavaString(env, m_lpStrW); + m_jtext = MakeJavaString(env, m_lpStrW, m_cStrW); } // Merge the string if necessary @@ -182,12 +182,12 @@ AwtInputTextInfor::~AwtInputTextInfor() { } -jstring AwtInputTextInfor::MakeJavaString(JNIEnv* env, LPWSTR lpStrW) { +jstring AwtInputTextInfor::MakeJavaString(JNIEnv* env, LPWSTR lpStrW, int cStrW) { - if (env == NULL || lpStrW == NULL) { + if (env == NULL || lpStrW == NULL || cStrW == 0) { return NULL; } else { - return JNU_NewStringPlatform(env, lpStrW); + return env->NewString(reinterpret_cast(lpStrW), cStrW); } } @@ -246,14 +246,14 @@ int AwtInputTextInfor::GetClauseInfor(int*& lpBndClauseW, jstring*& lpReadingCla } ::LCMapString(lcJPN, LCMAP_FULLWIDTH, lpHWStrW, cHWStrW, lpFWStrW, cFWStrW); - readingClauseW[cls] = MakeJavaString(env, lpFWStrW); + readingClauseW[cls] = MakeJavaString(env, lpFWStrW, cFWStrW); delete [] lpFWStrW; } else { - readingClauseW[cls] = MakeJavaString(env, lpHWStrW); + readingClauseW[cls] = MakeJavaString(env, lpHWStrW, cHWStrW); } } else { - readingClauseW[cls] = MakeJavaString(env, (LPWSTR)NULL); + readingClauseW[cls] = NULL; } } diff --git a/src/windows/native/sun/windows/awt_InputTextInfor.h b/src/windows/native/sun/windows/awt_InputTextInfor.h index 13626e78b48e17b190fa8641759f33de777d9e3d..4244fcf8b5d8497e6b483c7c5ca46b5400f182c8 100644 --- a/src/windows/native/sun/windows/awt_InputTextInfor.h +++ b/src/windows/native/sun/windows/awt_InputTextInfor.h @@ -58,7 +58,7 @@ class AwtInputTextInfor { ~AwtInputTextInfor(); private: /* helper function to return a java string.*/ - static jstring MakeJavaString(JNIEnv* env, LPWSTR lpStrW); + static jstring MakeJavaString(JNIEnv* env, LPWSTR lpStrW, int cStrW); LPARAM m_flags; /* The message LPARAM. */