mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Use jstring2string for more strings
This commit is contained in:
parent
1eea6cb36d
commit
09a6a30d8b
@ -977,15 +977,14 @@ namespace latinime {
|
||||
|
||||
size_t inputSize = env->GetArrayLength(inComposeX);
|
||||
|
||||
const char* cstr = env->GetStringUTFChars(context, nullptr);
|
||||
std::string contextString(cstr);
|
||||
env->ReleaseStringUTFChars(context, cstr);
|
||||
std::string contextString = "";
|
||||
if(context != nullptr) {
|
||||
contextString = jstring2string(env, context);
|
||||
}
|
||||
|
||||
std::string partialWordString;
|
||||
std::string partialWordString = "";
|
||||
if(partialWord != nullptr){
|
||||
const char* pwstr = env->GetStringUTFChars(partialWord, nullptr);
|
||||
partialWordString = std::string(pwstr);
|
||||
env->ReleaseStringUTFChars(partialWord, pwstr);
|
||||
partialWordString = jstring2string(env, partialWord);
|
||||
}
|
||||
|
||||
if(partialWordString.size() < inputSize) inputSize = partialWordString.size();
|
||||
|
@ -7,9 +7,13 @@
|
||||
#include "defines.h"
|
||||
|
||||
std::string jstring2string(JNIEnv *env, jstring jStr) {
|
||||
if(jStr == nullptr) {
|
||||
AKLOGE("jstring is null!");
|
||||
return "";
|
||||
}
|
||||
|
||||
const jsize stringUtf8Length = env->GetStringUTFLength(jStr);
|
||||
if (stringUtf8Length <= 0) {
|
||||
AKLOGE("Can't get jStr");
|
||||
return "";
|
||||
}
|
||||
char stringChars[stringUtf8Length + 1];
|
||||
|
Loading…
Reference in New Issue
Block a user