{$ifdef nn}begin end;{$endif} function IsStreamWithSignature(Stream: TStream; const Sign: AnsiString): boolean; var Buf: AnsiString; begin Result:= false; if Stream.Size=cMinSizeForProgress then begin NPercents:= Int64(NEnd)*100 div Stream.Size; if Abs(NPercents-FProgress)>=cMinIncForProgress then begin FProgress:= NPercents; if Assigned(FOnProgress) then FOnProgress(Self); end; end; //detect+skip Eol LineEnd:= cEndNone; if (Int64(NEnd)+CharSizeutf8->UnicodeString //else just string->UnicodeString if FEncodingCodepage='' then SW:= SA else begin {$ifdef laz15} SA:= ConvertEncodingToUTF8(SA, FEncodingCodepage, bEncoded); {$else} SA:= ConvertEncoding(SA, FEncodingCodepage, ''); {$endif} SW:= UTF8Decode(SA); end; LineAddRaw(SW, LineEnd); end; cEncUTF8: begin SA:= ''; SetLength(SA, Len); Move(Buf[NStart], SA[1], Len); SW:= UTF8Decode(SA); LineAddRaw(SW, LineEnd); end; cEncWideLE, cEncWideBE: begin SW:= ''; SetLength(SW, Len div 2); Move(Buf[NStart], SW[1], Len); if FEncoding=cEncWideBE then SW:= SSwapEndian(SW); LineAddRaw(SW, LineEnd); end; else DoEncError; end; end; NStart:= NEnd; if (NStart>=BufSize) then Break; until false; finally FreeMem(Buf); end; end; procedure TATStrings.LoadFromStream(Stream: TStream); begin DoClearUndo(true); DoLoadFromStream(Stream); DoFinalizeLoading; end; procedure TATStrings.LoadFromFile(const Filename: string); var fs: TFileStream; begin fs:= TFileStream.Create(Filename, fmOpenRead); try LoadFromStream(fs); finally FreeAndNil(fs); end; end; procedure TATStrings.DoFinalizeLoading; begin DoDetectEndings; ActionAddFakeLineIfNeeded; DoClearLineStates(false); DoClearUndo; Modified:= false; FProgress:= 0; end;