`diff` command tells binary files from text files.
So you don't have to detect binary file explicitly, IMHO.

Example result of `diff` from binary files.

```
$ diff /usr/bin/perl5.12 /usr/bin/perl5.16
Binary files /usr/bin/perl5.12 and /usr/bin/perl5.16 differ
```