Skip reading UTF-8 BOM at the beginning of INI files

This commit is contained in:
JosJuice 2015-06-05 18:32:58 +02:00
parent 2f2e514b54
commit 990d61b786
1 changed files with 6 additions and 0 deletions

View File

@ -311,6 +311,7 @@ bool IniFile::Load(const std::string& filename, bool keep_current_data)
return false;
Section* current_section = nullptr;
bool first_line = true;
while (!in.eof())
{
std::string line;
@ -323,6 +324,11 @@ bool IniFile::Load(const std::string& filename, bool keep_current_data)
return false;
}
// Skips the UTF-8 BOM at the start of files. Notepad likes to add this.
if (first_line && line.substr(0, 3) == "\xEF\xBB\xBF")
line = line.substr(3);
first_line = false;
#ifndef _WIN32
// Check for CRLF eol and convert it to LF
if (!line.empty() && line.at(line.size()-1) == '\r')