diff options
author | Max Kellermann <max@duempel.org> | 2008-10-31 13:57:10 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-31 13:57:10 +0100 |
commit | 6757c17689a3990f1daddd035d8dcc39b90e18b8 (patch) | |
tree | ec512f216ccbff14caa1e4bca620b777c76bf3e5 /src/tag.c | |
parent | f61bb4c8cf5df19afca03a15986cf621b46c9ae1 (diff) |
removed UTF-8 library, use GLib instead
Removed duplicated code.
Diffstat (limited to 'src/tag.c')
-rw-r--r-- | src/tag.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -20,11 +20,11 @@ #include "tag_internal.h" #include "tag_pool.h" #include "utils.h" -#include "utf8.h" #include "log.h" #include "conf.h" #include "song.h" +#include <glib.h> #include <assert.h> /** @@ -345,15 +345,23 @@ int tag_equal(const struct tag *tag1, const struct tag *tag2) static inline const char *fix_utf8(const char *str, size_t *length_r) { const char *temp; + GError *error = NULL; + gsize written; assert(str != NULL); - if (validUtf8String(str, *length_r)) + if (g_utf8_validate(str, *length_r, NULL)) return str; DEBUG("not valid utf8 in tag: %s\n",str); - temp = latin1StrToUtf8Dup(str); - *length_r = strlen(temp); + temp = g_convert(str, *length_r, "utf-8", "iso-8859-1", + NULL, &written, &error); + if (temp == NULL) { + g_error_free(error); + return str; + } + + *length_r = written; return temp; } |