From 84c6fd96a6b7437b9e7250db52ca19b828b0b3bf Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Tue, 12 Nov 2002 22:35:32 +0000 Subject: Fixed broken unicode_munge() git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2840 a1c6a512-1295-4272-9138-f99709370657 --- firmware/id3.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/firmware/id3.c b/firmware/id3.c index f09ccf4ab2..3ee25cac12 100644 --- a/firmware/id3.c +++ b/firmware/id3.c @@ -80,9 +80,6 @@ const int freqtab[][4] = {22050, 24000, 16000, 0}, /* MPEG version 2 */ }; -#define UNICODE_BOM_1 0xfffe -#define UNICODE_BOM_2 0xfeff - /* Checks to see if the passed in string is a 16-bit wide Unicode v2 string. If it is, we attempt to convert it to a 8-bit ASCII string (for valid 8-bit ASCII characters). If it's not unicode, we leave @@ -109,14 +106,16 @@ static int unicode_munge(char** string, int *len) { /* Unicode with or without BOM */ if(str[0] == 0x01 || str[0] == 0x02) { str++; - tmp = BYTES2INT(0, 0, str[1], str[2]); + tmp = BYTES2INT(0, 0, str[0], str[1]); - if(tmp == UNICODE_BOM_2) { /* Little endian? */ + /* Now check if there is a BOM (zero-width non-breaking space, 0xfeff) + and if it is in little or big endian format */ + if(tmp == 0xfffe) { /* Little endian? */ le = true; str += 2; } - if(tmp == UNICODE_BOM_1) /* Big endian? */ + if(tmp == 0xfeff) /* Big endian? */ str += 2; i = 0; @@ -133,10 +132,10 @@ static int unicode_munge(char** string, int *len) { else outstr[i++] = str[1]; } + str += 2; } while(str[0] || str[1]); *len = i; - (*string)++; /* Skip the encoding type byte */ return 0; } -- cgit v1.2.3