Recent

Author Topic: How can seperate binary file from text file  (Read 5754 times)

Imants

  • Full Member
  • ***
  • Posts: 198
How can seperate binary file from text file
« on: January 07, 2011, 09:44:18 am »
I just want to know if there is such a method in Lazarus or what would be principles to. So I could write code myself.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12597
  • FPC developer.
Re: How can seperate binary file from text file
« Reply #1 on: January 07, 2011, 10:13:14 am »
Maybe you should explain better what you mean. The difference between "text" and "binary" is not absolute (e.g. in some cases people see text in a different encoding as binary), so you need to define criteria.

Imants

  • Full Member
  • ***
  • Posts: 198
Re: How can seperate binary file from text file
« Reply #2 on: January 07, 2011, 11:04:05 am »
In my opinion Text files are files where is stored text which normal people can read. It can be UTF8 file (I know some systems treat it as binary file) or ASCII file.
And binary files are files where are stored binary data like picture files, music files, video files.

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1933
Re: How can seperate binary file from text file
« Reply #3 on: January 07, 2011, 11:10:31 am »
Either by filename extension or by file signature:

http://www.garykessler.net/library/file_sigs.html

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12597
  • FPC developer.
Re: How can seperate binary file from text file
« Reply #4 on: January 07, 2011, 11:25:29 am »
In my opinion Text files are files where is stored text which normal people can read.

That is dependant on the tool you view it with. If you display a file in the wrong codepage, it might look like binary gibberish.

Same for e.g. UTF-16 in a 1-byte encoding viewer.

Moreover, binary protocols might look largely like text (e.g. because the comment field of a file full of binary records is by far the greatest part, and is text)

Quote
And binary files are files where are stored binary data like picture files, music files, video files.

Determining _WHAT_ is in a binary file is very, very hard. The only workable solution is binarry is NOT text, and then test for an handful of specific formats you are interested in.

HiFi

  • Newbie
  • Posts: 1
Re: How can seperate binary file from text file
« Reply #5 on: January 07, 2011, 04:44:27 pm »
Either by filename extension or by file signature:

http://www.garykessler.net/library/file_sigs.html

Yep that seems quite self explanatory. Cheers for that.

 

TinyPortal © 2005-2018