summaryrefslogtreecommitdiff
path: root/junklib.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <waker@users.sourceforge.net>2014-06-15 21:21:43 +0200
committerGravatar Alexey Yakovenko <waker@users.sourceforge.net>2014-06-15 21:21:43 +0200
commit2206d1d9f961078d3424d94ed968f31eceb2c704 (patch)
treee5a8239baaa00b04748f71123550629d001486d8 /junklib.c
parent44689f826cfce9f44901e28a9c80ed44cc1405b1 (diff)
try shift-jis detection even if disabled, in case other detectors fail before returning the default cp1252
Diffstat (limited to 'junklib.c')
-rw-r--r--junklib.c11
1 files changed, 7 insertions, 4 deletions
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";
}