Skip to content

Commit 889affa

Browse files
committed
Handle UTF-8 BOM
1 parent 3dddf67 commit 889affa

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

source/plutosvg.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,18 @@ plutosvg_document_t* plutosvg_document_load_from_data(const char* data, int leng
12521252
{
12531253
if(length == -1)
12541254
length = strlen(data);
1255+
if(length >= 3) {
1256+
const uint8_t* buffer = (const uint8_t*)(data);
1257+
1258+
const uint8_t c1 = buffer[0];
1259+
const uint8_t c2 = buffer[1];
1260+
const uint8_t c3 = buffer[2];
1261+
if(c1 == 0xEF && c2 == 0xBB && c3 == 0xBF) {
1262+
data += 3;
1263+
length -= 3;
1264+
}
1265+
}
1266+
12551267
const char* it = data;
12561268
const char* end = it + length;
12571269

0 commit comments

Comments
 (0)