|
|
|
@ -21,7 +21,8 @@ void log_android(int prio, const char *fmt, ...) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jobject JNICALL
|
|
|
|
|
Java_eu_faircode_email_CharsetHelper_jni_1detect_1charset(JNIEnv *env, jclass type, jbyteArray _octets) {
|
|
|
|
|
Java_eu_faircode_email_CharsetHelper_jni_1detect_1charset(JNIEnv *env, jclass type,
|
|
|
|
|
jbyteArray _octets) {
|
|
|
|
|
int len = env->GetArrayLength(_octets);
|
|
|
|
|
jbyte *octets = env->GetByteArrayElements(_octets, nullptr);
|
|
|
|
|
|
|
|
|
@ -59,8 +60,9 @@ Java_eu_faircode_email_CharsetHelper_jni_1detect_1charset(JNIEnv *env, jclass ty
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
|
JNIEXPORT jstring JNICALL
|
|
|
|
|
Java_eu_faircode_email_TextHelper_jni_1detect_1language(JNIEnv *env, jclass clazz, jbyteArray _octets) {
|
|
|
|
|
JNIEXPORT jobject JNICALL
|
|
|
|
|
Java_eu_faircode_email_TextHelper_jni_1detect_1language(JNIEnv *env, jclass clazz,
|
|
|
|
|
jbyteArray _octets) {
|
|
|
|
|
int len = env->GetArrayLength(_octets);
|
|
|
|
|
jbyte *octets = env->GetByteArrayElements(_octets, nullptr);
|
|
|
|
|
|
|
|
|
@ -71,7 +73,15 @@ Java_eu_faircode_email_TextHelper_jni_1detect_1language(JNIEnv *env, jclass claz
|
|
|
|
|
|
|
|
|
|
env->ReleaseByteArrayElements(_octets, octets, JNI_ABORT);
|
|
|
|
|
|
|
|
|
|
return env->NewStringUTF(result.language.c_str());
|
|
|
|
|
jclass cls = env->FindClass("eu/faircode/email/TextHelper$DetectResult");
|
|
|
|
|
jmethodID ctor = env->GetMethodID(cls, "<init>", "(Ljava/lang/String;FZF)V");
|
|
|
|
|
jstring jlanguage = env->NewStringUTF(result.language.c_str());
|
|
|
|
|
return env->NewObject(
|
|
|
|
|
cls, ctor,
|
|
|
|
|
jlanguage,
|
|
|
|
|
(jfloat) result.probability,
|
|
|
|
|
(jint) result.is_reliable,
|
|
|
|
|
(jfloat) result.is_reliable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
|