Remove BOM when reading text files
This should restore pre-27e2e2f35ff780e1df79b034a00f025a6b7d1e44 behavior with regards to BOM accumulation in config files
This commit is contained in:
parent
cf059655e4
commit
698490d7fa
@ -70,6 +70,16 @@ BOOL ConfigFile::LoadFile(DWORD dwOpenMode)
|
||||
|
||||
dwLength = (DWORD)file.GetFileSize();
|
||||
|
||||
if (dwLength >= 3) // remove BOM if present
|
||||
{
|
||||
char buff[3];
|
||||
file.Read(&buff, 3);
|
||||
if (memcmp(buff, "\xEF\xBB\xBF", 3))
|
||||
file.SetPos(0, XFILE_BEGIN);
|
||||
else
|
||||
dwLength -= 3;
|
||||
}
|
||||
|
||||
LPSTR lpTempFileData = (LPSTR)Allocate(dwLength+5);
|
||||
file.Read(&lpTempFileData[2], dwLength);
|
||||
lpTempFileData[0] = lpTempFileData[dwLength+2] = 13;
|
||||
|
@ -65,6 +65,17 @@ public:
|
||||
|
||||
SetPos(0, XFILE_BEGIN);
|
||||
DWORD dwFileSize = (DWORD)GetFileSize();
|
||||
|
||||
if (dwFileSize >= 3) // remove BOM if present
|
||||
{
|
||||
char buff[3];
|
||||
Read(&buff, 3);
|
||||
if (memcmp(buff, "\xEF\xBB\xBF", 3))
|
||||
SetPos(0, XFILE_BEGIN);
|
||||
else
|
||||
dwFileSize -= 3;
|
||||
}
|
||||
|
||||
LPSTR lpFileDataUTF8 = (LPSTR)Allocate(dwFileSize+1);
|
||||
lpFileDataUTF8[dwFileSize] = 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user