summaryrefslogtreecommitdiff
path: root/apps/cuesheet.c
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2009-01-26 11:24:11 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2009-01-26 11:24:11 +0000
commit3c1dbb269f0ca1872bc61ecfffd88a54fb0de5d9 (patch)
tree5d09bad7518869e77fc69737bdabc075077aca8f /apps/cuesheet.c
parent29565c40f70d8aec52714f17551ecb1e4d166801 (diff)
Fix FS#9830 - utf8 encoded .cue files dont get displayed properly
Also fix a possible problem where the performer and songwriter tags could get cut off git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19858 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/cuesheet.c')
-rw-r--r--apps/cuesheet.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/apps/cuesheet.c b/apps/cuesheet.c
index 9788427a07..4b3f5e9bc4 100644
--- a/apps/cuesheet.c
+++ b/apps/cuesheet.c
@@ -145,6 +145,7 @@ bool parse_cuesheet(char *file, struct cuesheet *cue)
{
char line[MAX_PATH];
char *s;
+ bool utf8 = false;
DEBUGF("cue parse\n");
int fd = open_utf8(file,O_RDONLY);
@@ -153,6 +154,8 @@ bool parse_cuesheet(char *file, struct cuesheet *cue)
/* couln't open the file */
return false;
}
+ if(lseek(fd, 0, SEEK_CUR) > 0)
+ utf8 = true;
/* Initialization */
memset(cue, 0, sizeof(struct cuesheet));
@@ -206,9 +209,18 @@ bool parse_cuesheet(char *file, struct cuesheet *cue)
break;
}
- if (dest) {
- dest = iso_decode(string, dest, -1, MIN(strlen(string), MAX_NAME));
- *dest = '\0';
+ if (dest)
+ {
+ if (!utf8)
+ {
+ dest = iso_decode(string, dest, -1, MIN(strlen(string), MAX_NAME));
+ *dest = '\0';
+ }
+ else
+ {
+ strncpy(dest, string, MAX_NAME*3);
+ dest[MAX_NAME*3] = '\0';
+ }
}
}
}
@@ -219,10 +231,10 @@ bool parse_cuesheet(char *file, struct cuesheet *cue)
for (i = 0; i < cue->track_count; i++)
{
if (*(cue->tracks[i].performer) == '\0')
- strncpy(cue->tracks[i].performer, cue->performer, MAX_NAME);
+ strncpy(cue->tracks[i].performer, cue->performer, MAX_NAME*3);
if (*(cue->tracks[i].songwriter) == '\0')
- strncpy(cue->tracks[i].songwriter, cue->songwriter, MAX_NAME);
+ strncpy(cue->tracks[i].songwriter, cue->songwriter, MAX_NAME*3);
}
return true;