anchor.diff:  
             //If control chars present, then non-text
             if IsAsciiControlChar(n) then
  -          begin
  -            Result:= False;
  -            Break
  -          end;
  +            //ignore bad bytes at the (end), (end minus 1)
  +            // https://github.com/Alexey-T/CudaText/issues/2959
  +            if not (bReadAllFile and (i>=BytesRead-2)) then
  +            begin
  +              Result:= False;
  +              Break
  +            end;
   
             //Calculate freq table
             if DetectOEM then
  
positive.code:     BytesRead:= Str.Read(Buffer^, BufSize);
      if BytesRead > 0 then
        begin
          //Test UTF16 signature
          if ((Buffer[0]=#$ff) and (Buffer[1]=#$fe)) or
            ((Buffer[0]=#$fe) and (Buffer[1]=#$ff)) then
  
negative.code:   TableSize: Integer;
    Str: TFileStream;
    IsLE: boolean;
    bReadAllFile: boolean;
  begin
    Result:= False;
    //IsOEM:= False;
  