Index: FileTextLines.cpp =================================================================== --- FileTextLines.cpp (revision 18937) +++ FileTextLines.cpp (working copy) @@ -251,6 +251,38 @@ return FALSE; } + //check lines for internal null symbols + bool bFoundInternalNullSumbols = false; + size_t bytePos = 0; + LPBYTE pFileBufAsBytes = (LPBYTE)pFileBuf; + if ((m_UnicodeType == UTF8)||(m_UnicodeType == UTF8BOM)||(m_UnicodeType == ASCII)) + { + //no nulls at all + for(; bytePos < dwReadBytes; bytePos++) + { + if(pFileBufAsBytes[bytePos] == 0) + { + bFoundInternalNullSumbols = true; + } + } + } else // unicode: no two-byte nulls at the even position + { + for(; bytePos < dwReadBytes; bytePos+=2) + { + if(pFileBufAsBytes[bytePos] == 0 && pFileBufAsBytes[bytePos+1] == 0) + { + bFoundInternalNullSumbols = true; + } + } + } + if(bFoundInternalNullSumbols) + { + //todo: i18n + m_sErrorString.Format(_T("The file\n%s\nis not a valid text file!\nFound null symbol at pos=%u"), + (LPCTSTR)sFilePath, bytePos); + delete [] pFileBuf; + return FALSE; + } // we may have to convert the file content if ((m_UnicodeType == UTF8)||(m_UnicodeType == UTF8BOM)) {