Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Commit

Permalink
Ini::LoadFile() detects BOM
Browse files Browse the repository at this point in the history
fixes #40
  • Loading branch information
wipe2238 committed Mar 6, 2019
1 parent a767514 commit 4633a6b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Source/Shared/Ini.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,16 @@ bool Ini::LoadFile( const string& fname, bool unload /* = true */ )
if( unload )
Unload();

ifstream fstream( fname );
ifstream fstream;
fstream.open( fname, ios_base::in | ios_base::binary );

if( fstream.is_open() )
{
char bom[3] = { 0, 0, 0 };
fstream.read( bom, sizeof(bom) );
if( bom[0] != (char)0xEF || bom[1] != (char)0xBB || bom[2] != (char)0xBF )
fstream.seekg( 0, fstream.beg );

Parse( fstream );

return true;
Expand Down

0 comments on commit 4633a6b

Please sign in to comment.