From 990d61b7865197573c7b8b509ba867144ba24da8 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Fri, 5 Jun 2015 18:32:58 +0200 Subject: [PATCH] Skip reading UTF-8 BOM at the beginning of INI files --- Source/Core/Common/IniFile.cpp | 6 ++++++ 1 file changed, 6 insertions(+) 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')