hello.. i am trying to write a code that could detect if an arbitrary file is either binary or text mode.
any help would be appreciated π
Hi, You can get some char and look if they are all displayable char (ascii >32 and <128)...
You can get some char and look if they are all displayable char (ascii >32 and <128)...
i thought about something like that, but what if the text file contains some special chars like Γ‘, Γͺ, ΓΌ ??? their ascii codes are greater than 128.. π
Yes, but in head of file? if you read just 256 chars, you can get an esteeme don't so bad...
now i've tried the following code, and it seems to work, altough looks quite lame :rolleyes:
$output = file -b $physicalFile; if(!eregi("text", $output)) { // binary } else { // text }
file -b $physicalFile
anyone would know a better way??