Merge pull request #2529 from JosJuice/ini-skip-bom
Skip reading UTF-8 BOM at the beginning of INI files
This commit is contained in:
commit
c79dd40e72
|
@ -311,6 +311,7 @@ bool IniFile::Load(const std::string& filename, bool keep_current_data)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Section* current_section = nullptr;
|
Section* current_section = nullptr;
|
||||||
|
bool first_line = true;
|
||||||
while (!in.eof())
|
while (!in.eof())
|
||||||
{
|
{
|
||||||
std::string line;
|
std::string line;
|
||||||
|
@ -323,6 +324,11 @@ bool IniFile::Load(const std::string& filename, bool keep_current_data)
|
||||||
return false;
|
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
|
#ifndef _WIN32
|
||||||
// Check for CRLF eol and convert it to LF
|
// Check for CRLF eol and convert it to LF
|
||||||
if (!line.empty() && line.at(line.size()-1) == '\r')
|
if (!line.empty() && line.at(line.size()-1) == '\r')
|
||||||
|
|
Loading…
Reference in New Issue