File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -1324,8 +1324,23 @@ namespace RC
13241324 else
13251325 {
13261326 // 'mods.txt' exists, lets parse it
1327+
1328+ // First, check for BOM using a byte stream
1329+ std::ifstream bom_check (enabled_mods_file, std::ios::binary);
1330+ char bom[3 ] = {0 };
1331+ bom_check.read (bom, 3 );
1332+ bool has_bom = (bom[0 ] == ' \xEF ' && bom[1 ] == ' \xBB ' && bom[2 ] == ' \xBF ' );
1333+ bom_check.close ();
1334+
1335+ // Now open the actual stream
13271336 StreamIType mods_stream{enabled_mods_file};
13281337
1338+ // If BOM was detected, skip the first "character" (which will be the BOM interpreted as a wide char)
1339+ if (has_bom) {
1340+ wchar_t discard;
1341+ mods_stream.get (discard);
1342+ }
1343+
13291344 StringType current_line;
13301345 while (std::getline (mods_stream, current_line))
13311346 {
You can’t perform that action at this time.
0 commit comments