From cc3c9383d0ba49363eded879f2bbef3f833df39c Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Fri, 15 Jan 2010 22:19:21 +0100 Subject: better (?) charset detection for id3v2.4 tags --- junklib.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'junklib.c') diff --git a/junklib.c b/junklib.c index d821775c..d6e3c63e 100644 --- a/junklib.c +++ b/junklib.c @@ -316,12 +316,7 @@ convstr_id3v2_4 (const unsigned char* str, int sz) { // hack to add limited cp1251 recoding support - if (*str == 0) { - // iso8859-1 - trace ("iso8859-1\n"); - enc = "iso8859-1"; - } - else if (*str == 3) { + if (*str == 3) { // utf8 trace ("utf8\n"); strncpy (out, str+1, 2047); @@ -337,6 +332,14 @@ convstr_id3v2_4 (const unsigned char* str, int sz) { trace ("utf16be\n"); enc = "UTF-16BE"; } +#if 0 + // NOTE: some dumb taggers put non-iso8859-1 text with enc=0 + else if (*str == 0) { + // iso8859-1 + trace ("iso8859-1\n"); + enc = "iso8859-1"; + } +#endif else { if (can_be_russian (&str[1])) { enc = "cp1251"; @@ -815,6 +818,10 @@ junk_read_id3v2 (playItem_t *it, DB_FILE *fp) { else if (version_major == 3) { sz = (readptr[3] << 0) | (readptr[2] << 8) | (readptr[1] << 16) | (readptr[0] << 24); } + else { + trace ("unknown id3v2 version (2.%d.%d)\n", version_major, version_minor); + return -1; + } readptr += 4; trace ("got frame %s, size %d, pos %d, tagsize %d\n", frameid, sz, readptr-tag, size); if (readptr - tag >= size - sz) { -- cgit v1.2.3