Page 1 of 1

[answered]How to determine plaintext content?

Posted: 04 Aug 2014 19:01
by bdeshi
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>

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
}
</pseudocode>

Re: How to determine plaintext content?

Posted: 04 Aug 2014 19:14
by TheQwerty
How about the filetype SC?

Code: Select all

help('idh_scripting_comref.htm#idh_sc_filetype');
[/size]

Re: How to determine plaintext content?

Posted: 04 Aug 2014 19:19
by bdeshi
You make me wonder about my eyesight.

Re: How to determine plaintext content?

Posted: 04 Aug 2014 19:26
by TheQwerty
Whatever could you mean? :whistle:

Re: [answered]How to determine plaintext content?

Posted: 04 Aug 2014 19:51
by bdeshi
In any case, one thing led to another, I had an idea from this topic and now I [have to || need to || want to] write the whole script all over again. [ :evil: || :twisted: ]
Thanks.

Re: [answered]How to determine plaintext content?

Posted: 05 Aug 2014 00:56
by PeterH
SammaySarkar wrote:In any case, one thing led to another, I had an idea from this topic and now I [have to || need to || want to] write the whole script all over again. [ :evil: || :twisted: ]
Thanks.
I think it doesn't matter:
- it's only pseudo code
- it misses an "{"
:mrgreen:

:oops: Sorry - I couldn't resist (again) :whistle:
:lol: :lol: