summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2002-11-12 22:35:32 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2002-11-12 22:35:32 +0000
commit84c6fd96a6b7437b9e7250db52ca19b828b0b3bf (patch)
tree3ae0b2259e8d0f72550e63903b958bc81b7bf3e5 /firmware
parent099a6b58d1cca1fb052aa453cf1dec524d3ba35a (diff)
downloadrockbox-84c6fd96a6b7437b9e7250db52ca19b828b0b3bf.tar.gz
rockbox-84c6fd96a6b7437b9e7250db52ca19b828b0b3bf.zip
Fixed broken unicode_munge()
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2840 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/id3.c13
1 files 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] =
80 {22050, 24000, 16000, 0}, /* MPEG version 2 */ 80 {22050, 24000, 16000, 0}, /* MPEG version 2 */
81}; 81};
82 82
83#define UNICODE_BOM_1 0xfffe
84#define UNICODE_BOM_2 0xfeff
85
86/* Checks to see if the passed in string is a 16-bit wide Unicode v2 83/* Checks to see if the passed in string is a 16-bit wide Unicode v2
87 string. If it is, we attempt to convert it to a 8-bit ASCII string 84 string. If it is, we attempt to convert it to a 8-bit ASCII string
88 (for valid 8-bit ASCII characters). If it's not unicode, we leave 85 (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) {
109 /* Unicode with or without BOM */ 106 /* Unicode with or without BOM */
110 if(str[0] == 0x01 || str[0] == 0x02) { 107 if(str[0] == 0x01 || str[0] == 0x02) {
111 str++; 108 str++;
112 tmp = BYTES2INT(0, 0, str[1], str[2]); 109 tmp = BYTES2INT(0, 0, str[0], str[1]);
113 110
114 if(tmp == UNICODE_BOM_2) { /* Little endian? */ 111 /* Now check if there is a BOM (zero-width non-breaking space, 0xfeff)
112 and if it is in little or big endian format */
113 if(tmp == 0xfffe) { /* Little endian? */
115 le = true; 114 le = true;
116 str += 2; 115 str += 2;
117 } 116 }
118 117
119 if(tmp == UNICODE_BOM_1) /* Big endian? */ 118 if(tmp == 0xfeff) /* Big endian? */
120 str += 2; 119 str += 2;
121 120
122 i = 0; 121 i = 0;
@@ -133,10 +132,10 @@ static int unicode_munge(char** string, int *len) {
133 else 132 else
134 outstr[i++] = str[1]; 133 outstr[i++] = str[1];
135 } 134 }
135 str += 2;
136 } while(str[0] || str[1]); 136 } while(str[0] || str[1]);
137 137
138 *len = i; 138 *len = i;
139 (*string)++; /* Skip the encoding type byte */
140 return 0; 139 return 0;
141 } 140 }
142 141