read through the file, check the existence of non printable char, if not exist, you can suppose this file is a text file.
check the existence of non printable char怎么判断?
isprint, iswprint int isprint( int c );int iswprint( wint_t c );Each of these routines returns true if c is a particular representation of a printable character.
int isprint( int c );int iswprint( wint_t c );Each of these routines returns true if c is a particular representation of a printable character.
如果一个文本是Unicode的,采用如上办法估计……