aboutsummaryrefslogtreecommitdiffstats
path: root/src/tag.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-04-13 02:20:46 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-04-13 02:20:46 +0000
commit375e3ffed496c995383156f9675fa95f145e05bf (patch)
tree70fe33adf511043461fc41eb1d7b42c6145846a4 /src/tag.c
parent6bc445d00f7479c106828651abc3d76ddee5a5a5 (diff)
downloadmpd-375e3ffed496c995383156f9675fa95f145e05bf.tar.gz
mpd-375e3ffed496c995383156f9675fa95f145e05bf.tar.xz
mpd-375e3ffed496c995383156f9675fa95f145e05bf.zip
add my own utf8/ascii converters and utf8 validator
validate all mpd tags on import, if they are invalid, assume they are ascii and convert to utf8 git-svn-id: https://svn.musicpd.org/mpd/trunk@707 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/tag.c')
-rw-r--r--src/tag.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/tag.c b/src/tag.c
index bda1810be..2fabf5639 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -24,6 +24,7 @@
#include "mp4_decode.h"
#include "aac_decode.h"
#include "utils.h"
+#include "utf8.h"
#include <sys/stat.h>
#include <stdlib.h>
@@ -57,6 +58,22 @@ void printMpdTag(FILE * fp, MpdTag * tag) {
if(tag->time>=0) myfprintf(fp,"Time: %i\n",tag->time);
}
+#define fixUtf8(str) { \
+ if(str && !validUtf8String(str)) { \
+ char * temp; \
+ temp = asciiStrToUtf8Dup(str); \
+ free(str); \
+ str = temp; \
+ } \
+}
+
+void validateUtf8Tag(MpdTag * tag) {
+ fixUtf8(tag->artist);
+ fixUtf8(tag->album);
+ fixUtf8(tag->track);
+ fixUtf8(tag->title);
+}
+
#ifdef HAVE_ID3TAG
char * getID3Info(struct id3_tag * tag, char * id) {
struct id3_frame const * frame;
@@ -145,6 +162,8 @@ MpdTag * audiofileTagDup(char * utf8file) {
ret->time = time;
}
+ if(ret) validateUtf8Tag(ret);
+
return ret;
}
#endif
@@ -163,6 +182,8 @@ MpdTag * mp3TagDup(char * utf8file) {
ret->time = time;
}
+ if(ret) validateUtf8Tag(ret);
+
return ret;
}
#endif
@@ -179,6 +200,8 @@ MpdTag * aacTagDup(char * utf8file) {
ret->time = time;
}
+ if(ret) validateUtf8Tag(ret);
+
return ret;
}
@@ -267,6 +290,8 @@ MpdTag * mp4TagDup(char * utf8file) {
}
}
+ if(ret) validateUtf8Tag(ret);
+
return ret;
}
#endif
@@ -329,6 +354,8 @@ MpdTag * oggTagDup(char * utf8file) {
ov_clear(&vf);
+ if(ret) validateUtf8Tag(ret);
+
return ret;
}
#endif
@@ -441,6 +468,8 @@ MpdTag * flacTagDup(char * utf8file) {
}
}
+ if(ret) validateUtf8Tag(ret);
+
return ret;
}
#endif