[answered]How to determine plaintext content?
Posted: 04 Aug 2014 19:01
Hey all, What's the best way (if there is) to determine if a file content is readable plaintext?
I want to display the content as is, or display the raw hex (using hexdump with r switch) if the content is not plaintext.
<pseudocode></pseudocode>
I want to display the content as is, or display the raw hex (using hexdump with r switch) if the content is not plaintext.
<pseudocode>
Code: Select all
if (file content is textual){
$data = readfile($srcfile); //read in as text
} elseif (file content is not textual)
$data = hexdump(readfile($srcfile,b),,r); //read in data as hex
}