skip utf8 BOM in config file

This commit is contained in:
IntelOrca 2015-02-16 23:51:04 +00:00
parent 7f0ed995b5
commit af1d5faa90
1 changed files with 6 additions and 0 deletions

View File

@ -250,6 +250,12 @@ bool config_open(const utf8string path)
lineBufferCapacity = 64;
lineBuffer = malloc(lineBufferCapacity);
lineLength = 0;
// Skim UTF-8 byte order mark
fread(lineBuffer, 3, 1, file);
if (!(lineBuffer[0] == 0xEF && lineBuffer[1] == 0xBB && lineBuffer[2] == 0xBF))
fseek(file, 0, SEEK_SET);
while ((c = fgetc(file)) != EOF) {
if (c == '\n' || c == '\r') {
lineBuffer[lineLength++] = 0;