Code

screen_lyrics: character set conversion
authorMax Kellermann <max@duempel.org>
Thu, 2 Oct 2008 17:01:30 +0000 (19:01 +0200)
committerMax Kellermann <max@duempel.org>
Thu, 2 Oct 2008 17:01:30 +0000 (19:01 +0200)
Convert the lyrics to the current character set before displaying
them.

src/screen_lyrics.c

index 927b3dd9c486e0009af6d17ac5f7adeed49c9fd1..b1812de31154764efee7db1925bef9296f7d4f2f 100644 (file)
@@ -26,6 +26,7 @@
 #include "screen_utils.h"
 #include "strfsong.h"
 #include "lyrics.h"
+#include "charset.h"
 #include "gcc.h"
 
 #define _GNU_SOURCE
@@ -221,10 +222,17 @@ static int store_lyr_hd(void)
 static const char *
 list_callback(unsigned idx, mpd_unused int *highlight, mpd_unused void *data)
 {
+       static char buffer[256];
+       char *value;
+
        if (idx >= current.lines->len)
                return NULL;
 
-       return g_ptr_array_index(current.lines, idx);
+       value = utf8_to_locale(g_ptr_array_index(current.lines, idx));
+       g_strlcpy(buffer, value, sizeof(buffer));
+       free(value);
+
+       return buffer;
 }