mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-07-26 18:00:38 +00:00
fix: handle UTF-8 BOM-prefixed input (#919)
Fixes https://github.com/Laupetin/OpenAssetTools/issues/771
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
#include "IParserLineStream.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace
|
||||
{
|
||||
// A UTF-8 BOM is an encoding signature and is only valid at the start of a file.
|
||||
constexpr std::string_view UTF8_BOM("\xEF\xBB\xBF", 3);
|
||||
} // namespace
|
||||
|
||||
ParserLine::ParserLine()
|
||||
: m_line_number(0)
|
||||
{
|
||||
@@ -10,6 +18,8 @@ ParserLine::ParserLine(std::shared_ptr<std::string> filename, const int lineNumb
|
||||
m_line_number(lineNumber),
|
||||
m_line(std::move(line))
|
||||
{
|
||||
if (m_line_number == 1 && m_line.starts_with(UTF8_BOM))
|
||||
m_line.erase(0, UTF8_BOM.size());
|
||||
}
|
||||
|
||||
bool ParserLine::IsEof() const
|
||||
|
||||
Reference in New Issue
Block a user