From ec8317b1be39f6998fbd3dd069e01a0596f2abf7 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 25 Oct 2020 11:27:35 +0100 Subject: [PATCH] Log sample size --- app/src/main/java/eu/faircode/email/CharsetHelper.java | 6 ++++-- app/src/main/jni/charset.cc | 9 +++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/CharsetHelper.java b/app/src/main/java/eu/faircode/email/CharsetHelper.java index 0e29f3d47a..41a6c751c5 100644 --- a/app/src/main/java/eu/faircode/email/CharsetHelper.java +++ b/app/src/main/java/eu/faircode/email/CharsetHelper.java @@ -111,18 +111,20 @@ class CharsetHelper { private static class DetectResult { String charset; + int sample_size; int bytes_consumed; boolean is_reliable; - DetectResult(String charset, int bytes_consumed, boolean is_reliable) { + DetectResult(String charset, int sample_size, int bytes_consumed, boolean is_reliable) { this.charset = charset; + this.sample_size = sample_size; this.bytes_consumed = bytes_consumed; this.is_reliable = is_reliable; } @Override public String toString() { - return charset + " c=" + bytes_consumed + " r=" + is_reliable; + return charset + " s=" + bytes_consumed + "/" + sample_size + " r=" + is_reliable; } } } diff --git a/app/src/main/jni/charset.cc b/app/src/main/jni/charset.cc index 04d0b2cb52..d76ab2f190 100644 --- a/app/src/main/jni/charset.cc +++ b/app/src/main/jni/charset.cc @@ -42,7 +42,12 @@ Java_eu_faircode_email_CharsetHelper_jni_1detect(JNIEnv *env, jclass type, jbyte env->ReleaseByteArrayElements(_octets, octets, JNI_ABORT); jclass cls = env->FindClass("eu/faircode/email/CharsetHelper$DetectResult"); - jmethodID ctor = env->GetMethodID(cls, "", "(Ljava/lang/String;IZ)V"); + jmethodID ctor = env->GetMethodID(cls, "", "(Ljava/lang/String;IIZ)V"); jstring jname = env->NewStringUTF(name); - return env->NewObject(cls, ctor, jname, (jint) bytes_consumed, (jboolean) is_reliable); + return env->NewObject( + cls, ctor, + jname, + (jint) len, + (jint) bytes_consumed, + (jboolean) is_reliable); }