From a48c2fe2c2d13fbc879a6b5111fc9f3c866ac5b3 Mon Sep 17 00:00:00 2001 From: Kalle Wallin Date: Fri, 19 Mar 2004 19:15:43 +0000 Subject: Added iconv support git-svn-id: https://svn.musicpd.org/ncmpc/trunk@308 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- mpc.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'mpc.c') diff --git a/mpc.c b/mpc.c index ccb083590..f62d9789c 100644 --- a/mpc.c +++ b/mpc.c @@ -16,6 +16,8 @@ #include "mpc.h" #include "options.h" +#define MAX_SONG_LENGTH 1024 + void mpc_update_song(mpd_client_t *c) { @@ -186,21 +188,31 @@ mpc_playlist_get_song(mpd_client_t *c, int n) char * mpc_get_song_name(mpd_Song *song) { + static char buf[MAX_SONG_LENGTH]; + char *name; + if( song->title ) { if( song->artist ) { - static char buf[512]; - - snprintf(buf, 512, "%s - %s", song->artist, song->title); - return utf8(buf); + snprintf(buf, MAX_SONG_LENGTH, "%s - %s", song->artist, song->title); + name = utf8_to_locale(buf); + strncpy(buf, name, MAX_SONG_LENGTH); + free(name); + return buf; } else { - return utf8(song->title); + name = utf8_to_locale(song->title); + strncpy(buf, name, MAX_SONG_LENGTH); + free(name); + return buf; } } - return utf8(basename(song->file)); + name = utf8_to_locale(song->file); + strncpy(buf, name, MAX_SONG_LENGTH); + free(name); + return buf; } int -- cgit v1.2.3