Revert "Experiment: search attachment content"

This reverts commit b03f0ebe6b.
This commit is contained in:
M66B
2023-08-10 07:26:49 +02:00
parent 1913d5e3a7
commit 8412a69b39
10 changed files with 21 additions and 199 deletions

View File

@@ -225,7 +225,19 @@ public class CharsetHelper {
try {
byte[] octets = text.getBytes(StandardCharsets.ISO_8859_1);
DetectResult detected = _detect(octets, ref);
byte[] sample;
if (octets.length < MAX_SAMPLE_SIZE)
sample = octets;
else {
sample = new byte[MAX_SAMPLE_SIZE];
System.arraycopy(octets, 0, sample, 0, MAX_SAMPLE_SIZE);
}
Log.i("compact_enc_det sample=" + sample.length);
DetectResult detected = jni_detect_charset(sample,
ref == null ? StandardCharsets.ISO_8859_1.name() : ref.name(),
Locale.getDefault().getLanguage());
if (TextUtils.isEmpty(detected.charset)) {
Log.e("compact_enc_det result=" + detected);
@@ -250,34 +262,7 @@ public class CharsetHelper {
}
}
public static Charset detect(byte[] octets, Charset ref) {
try {
DetectResult detected = _detect(octets, ref);
if (TextUtils.isEmpty(detected.charset))
return null;
return Charset.forName(detected.charset);
} catch (Throwable ex) {
Log.w(ex);
return null;
}
}
private static DetectResult _detect(byte[] octets, Charset ref) {
byte[] sample;
if (octets.length < MAX_SAMPLE_SIZE)
sample = octets;
else {
sample = new byte[MAX_SAMPLE_SIZE];
System.arraycopy(octets, 0, sample, 0, MAX_SAMPLE_SIZE);
}
Log.i("compact_enc_det sample=" + sample.length);
return jni_detect_charset(sample,
ref == null ? StandardCharsets.ISO_8859_1.name() : ref.name(),
Locale.getDefault().getLanguage());
}
public static class DetectResult {
private static class DetectResult {
String charset;
int sample_size;
int bytes_consumed;