From 2206d1d9f961078d3424d94ed968f31eceb2c704 Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Sun, 15 Jun 2014 21:21:43 +0200 Subject: try shift-jis detection even if disabled, in case other detectors fail before returning the default cp1252 --- junklib.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'junklib.c') diff --git a/junklib.c b/junklib.c index d4d82583..a3d82e93 100644 --- a/junklib.c +++ b/junklib.c @@ -714,9 +714,6 @@ can_be_chinese (const uint8_t *str, int sz) { static int can_be_shift_jis (const unsigned char *str, int size) { - if (!enable_shift_jis_detection) { - return 0; - } unsigned char out[size*4]; if (size < 2) { @@ -3674,7 +3671,7 @@ junk_detect_charset_len (const char *s, int len) { return NULL; // means no recoding required } // try shift-jis - if (len > 10 && can_be_shift_jis (s, len)) { + if (enable_shift_jis_detection && can_be_shift_jis (s, len)) { return "shift-jis"; } // hack to add cp936 support @@ -3686,6 +3683,12 @@ junk_detect_charset_len (const char *s, int len) { return "cp1251"; } + // if shift_jis detection is disabled, but russian and chinese failed, + // try it anyway + if (!enable_shift_jis_detection && can_be_shift_jis (s, len)) { + return "shift_jis"; + } + return "cp1252"; } -- cgit v1.2.3