From: Stefan Mahlitz Date: 2007-08-22T16:25:43+09:00 Subject: Re: Test if file is binary ? Simon Krahnke wrote: > * Stefan Mahlitz (22:40) schrieb: > >> That's why clearcase (on windows) claimed my pure-ascii xml-file was >> non-text (and did refuse to check it in). One line exceeded 8000 characters. > > You can't seriously treat a file with lines longer than 8000 characters > as line oriented. It's far from being readable by a human. You declare > that file as application/xml. Maybe this was a bad example. You are right, the xml-file would be best treated by clearcase as application/xml or text/xml. This did not work (and I was bitten by this recently - so this strange behaviour was fresh when I read your email). But I cannot see the problem with text-files containing long lines. If I write a single paragraph with more than 1000 or 8000 characters - why shouldn't this be text? Why do you think it is not readable? > One small change in that line will produce a patch of more than 8000 > characters. And if that change is at the end of the line the diff tool > will have to use 4 pages of memory for the compare. Sorry, I fail to see your point. Are we really judging whether a file is text by how much memory pages a diff will take or how many characters a patch has? I couldn't find a definition of text except that text means absence of binary data. This is weak - so I would follow your definition - A text file is a file which can be read by a human. >> This is on my personal list of 'bad practices', but it may be >> appropriate to others. > > I think it's bad practice to declare something with huge lines as text. Well, I disagree. But to get (slightly at least) ontopic again, if I would have to detect whether a file is text I would go with a combination of Robert Klemmes and Bertram Schrapfs solutions. Stefan