diff options
| author | JosJuice <josjuice@gmail.com> | 2015-06-05 18:32:58 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2015-06-05 18:32:58 +0200 |
| commit | 990d61b7865197573c7b8b509ba867144ba24da8 (patch) | |
| tree | f2088e582b6ac87670499a0421bec6c6dc2d1878 /Source/Core/Common/IniFile.cpp | |
| parent | 2f2e514b54cdb327f07471b562ad1ad6a375c509 (diff) | |
Skip reading UTF-8 BOM at the beginning of INI files
Diffstat (limited to 'Source/Core/Common/IniFile.cpp')
| -rw-r--r-- | Source/Core/Common/IniFile.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Source/Core/Common/IniFile.cpp b/Source/Core/Common/IniFile.cpp index dda4f5e115..9ea8f50533 100644 --- a/Source/Core/Common/IniFile.cpp +++ b/Source/Core/Common/IniFile.cpp @@ -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') |
