summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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