From a5ad305f67147af0bf36f69a37f61fe68c4f3486 Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Fri, 2 Apr 2010 16:06:07 +0200 Subject: added charset detection / utf8 conversion to adplug plugin --- plugins/adplug/adplug-db.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'plugins/adplug') diff --git a/plugins/adplug/adplug-db.cpp b/plugins/adplug/adplug-db.cpp index 5a285ef4..b97a42da 100644 --- a/plugins/adplug/adplug-db.cpp +++ b/plugins/adplug/adplug-db.cpp @@ -209,6 +209,20 @@ adplug_get_extension (const char *fname) { return "adplug-unknown"; } +static void +adplug_add_meta (DB_playItem_t *it, const char *key, const char *value) { + if (!value) { + return; + } + const char *charset = deadbeef->junk_detect_charset (value); + if (charset) { + int l = strlen (value); + char str[1024]; + deadbeef->junk_recode (value, l, str, sizeof (str), charset); + deadbeef->pl_add_meta (it, key, str); + } +} + DB_playItem_t * adplug_insert (DB_playItem_t *after, const char *fname) { // read information from the track @@ -235,16 +249,16 @@ adplug_insert (DB_playItem_t *after, const char *fname) { deadbeef->pl_set_item_duration (it, p->songlength (i)/1000.f); // add metainfo if (!p->gettitle().empty()) { - deadbeef->pl_add_meta (it, "title", p->gettitle().c_str()); + adplug_add_meta (it, "title", p->gettitle().c_str()); } else { - deadbeef->pl_add_meta (it, "title", NULL); + adplug_add_meta (it, "title", NULL); } if (!p->getdesc().empty()) { - deadbeef->pl_add_meta (it, "comment", p->getdesc().c_str()); + adplug_add_meta (it, "comment", p->getdesc().c_str()); } if (!p->getauthor().empty()) { - deadbeef->pl_add_meta (it, "artist", p->getauthor().c_str()); + adplug_add_meta (it, "artist", p->getauthor().c_str()); } // insert after = deadbeef->pl_insert_item (after, it); -- cgit v1.2.3