The linux file command does a very good job in recognising file types and gives very fine-grained results. The diff tool is able to tell binary files f
file
diff
These days the term "text file" is ambiguous, because a text file can be encoded in ASCII, ISO-8859-*, UTF-8, UTF-16, UTF-32 and so on.
See here for how Subversion does it.