diff options
author | Max Kellermann <max@duempel.org> | 2008-10-15 19:36:30 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-15 19:36:30 +0200 |
commit | 8746a58ab93f0662bf1e8b91a36c261822ffeed5 (patch) | |
tree | ecacc9d8c682cb2621cbd8d3298ef7e3ee056542 /src/tag_id3.c | |
parent | e89599eaad23990973efd43f01cb802917a31cff (diff) |
path, tag_id3: use g_convert() instead of charConv.c
GLib provides an easier API for character set conversion than iconv().
Use g_convert() / g_convert_with_fallback() for all character
conversions. We should optimize the path.h API later to return a
newly allocated buffer, so we can just pass GLib's return value.
Diffstat (limited to 'src/tag_id3.c')
-rw-r--r-- | src/tag_id3.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/tag_id3.c b/src/tag_id3.c index 7fcf9f0a..5d144b58 100644 --- a/src/tag_id3.c +++ b/src/tag_id3.c @@ -21,9 +21,9 @@ #include "utils.h" #include "log.h" #include "conf.h" -#include "charConv.h" #ifdef HAVE_ID3TAG +#include <glib.h> #include <id3tag.h> #endif @@ -54,16 +54,21 @@ static id3_utf8_t * processID3FieldString (int is_id3v1, const id3_ucs4_t *ucs4, /* use encoding field here? */ if (is_id3v1 && (encoding = getConfigParamValue(CONF_ID3V1_ENCODING))) { + GError *error = NULL; + isostr = id3_ucs4_latin1duplicate(ucs4); if (mpd_unlikely(!isostr)) { return NULL; } - setCharSetConversion("UTF-8", encoding); - utf8 = xmalloc(strlen((char *)isostr) + 1); - utf8 = (id3_utf8_t *)char_conv_str((char *)utf8, (char *)isostr); - if (!utf8) { + + utf8 = (id3_utf8_t *) + g_convert_with_fallback((const char*)isostr, -1, + encoding, "utf-8", + NULL, NULL, NULL, &error); + if (utf8 == NULL) { DEBUG("Unable to convert %s string to UTF-8: " "'%s'\n", encoding, isostr); + g_error_free(error); free(isostr); return NULL; } |