diff options
author | Alexey Yakovenko <waker@users.sourceforge.net> | 2014-01-05 17:49:52 +0100 |
---|---|---|
committer | Alexey Yakovenko <waker@users.sourceforge.net> | 2014-01-05 17:51:45 +0100 |
commit | 0cfcbe2bf6531b70c7213dbb4893d6333b61e7ed (patch) | |
tree | 90f2d36a60ee1d9486264b682b25396a50a155d6 | |
parent | a66c46305373f8e66655777298051a506b2e8cf0 (diff) |
invalid cuesheet lines are replaced with placeholders; added shift-jis recoding to cuesheet parser
-rw-r--r-- | junklib.c | 11 | ||||
-rw-r--r-- | playlist.c | 18 |
2 files changed, 22 insertions, 7 deletions
@@ -483,7 +483,7 @@ junk_iconv (const char *in, int inlen, char *out, int outlen, const char *cs_in, int err = errno; iconv_close (cd); - //trace ("iconv -f %s -t %s '%s': returned %d, inbytes %d/%d, outbytes %d/%d, errno=%d\n", cs_in, cs_out, in, res, inlen, inbytesleft, outlen, outbytesleft, err); + //trace ("iconv -f %s -t %s '%s': returned %d, inbytes %d/%d, outbytes %d/%d, errno=%d\n", cs_in, cs_out, in, (int)res, inlen, (int)inbytesleft, outlen, (int)outbytesleft, err); if (res == -1) { return -1; } @@ -3522,18 +3522,21 @@ junk_id3v2_read (playItem_t *it, DB_FILE *fp) { const char * junk_detect_charset (const char *s) { + size_t len = strlen (s); + // check if that's already utf8 - if (u8_valid (s, strlen (s), NULL)) { + if (u8_valid (s, len, NULL)) { return NULL; // means no recoding required } // hack to add cp936 support - if (can_be_chinese (s, strlen (s))) { + if (can_be_chinese (s, len)) { return "cp936"; } // check if that could be non-latin1 (too many nonascii chars) - if (can_be_russian (s, strlen (s))) { + if (can_be_russian (s, len)) { return "cp1251"; } + return "cp1252"; } @@ -883,9 +883,21 @@ pl_get_qvalue_from_cue (const uint8_t *p, int sz, char *out) { } // recode int l = strlen (str); - char in[l+1]; - memcpy (in, str, l+1); - junk_recode (in, l, str, sz, charset); + char recbuf[l*10]; + int res = junk_recode (str, l, recbuf, sizeof (recbuf)-1, charset); + if (res > 0) { + strcpy (str, recbuf); + } + else + { + res = junk_recode (str, l, recbuf, sizeof (recbuf)-1, "SHIFT-JIS"); + if (res > 0) { + strcpy (str, recbuf); + } + else { + strcpy (str, "<UNRECOGNIZED CHARSET>"); + } + } } static void |