From 055ca014541453a3a2e07db6902b16f9406bf530 Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Fri, 13 Jun 2014 19:11:37 +0200 Subject: improved cuesheet charset detection --- junklib.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'junklib.c') diff --git a/junklib.c b/junklib.c index 05e58fc9..37692c96 100644 --- a/junklib.c +++ b/junklib.c @@ -3639,15 +3639,13 @@ junk_id3v2_read (playItem_t *it, DB_FILE *fp) { } const char * -junk_detect_charset (const char *s) { - size_t len = strlen (s); - +junk_detect_charset_len (const char *s, int len) { // check if that's already utf8 if (u8_valid (s, len, NULL)) { return NULL; // means no recoding required } // try shift-jis - if (can_be_shift_jis (s, len)) { + if (len > 10 && can_be_shift_jis (s, len)) { return "shift-jis"; } // hack to add cp936 support @@ -3662,6 +3660,12 @@ junk_detect_charset (const char *s) { return "cp1252"; } +const char * +junk_detect_charset (const char *s) { + size_t len = strlen (s); + return junk_detect_charset_len (s, len); +} + int junk_recode (const char *in, int inlen, char *out, int outlen, const char *cs) { return junk_iconv (in, inlen, out, outlen, cs, UTF8_STR); -- cgit v1.2.3