05-26-2017 04:20 AM
Hi,
How can i determine if the file and binary o a text by looking at the content and without checking the extensions?
I find this solution but i dont know how i an do it in labview.
Please help me if you have other method easier.
-Read first 2K bytes (or less if file is not enough big) -If a file contains only the decimal bytes 9–13, 32–126, it's probably a pure ASCII text file -If, in addition to the above bytes, the file contains only the decimal bytes 128–255, it's probably a text file in an 8-bit or variable-length ASCII-based encoding such as ISO-8859-1, UTF-8 or ASCII+Big5. -If not, for some purposes you may be able to stop here and consider the file to be binary -If a file doesn't meet the above constraints, examine the first 2–4 bytes of the file for a byte-order mark => UNICODE (UTF-8, UTF-16 or a text file encoded in the current code page of the host operating system) EF BB BF UTF-8 FF FE UTF-16, little endian FE FF UTF-16, big endian FF FE 00 00 UTF-32, little endian 00 00 FE FF UTF-32, big-endian
Thank you ,
05-26-2017 07:28 PM - edited 05-26-2017 07:31 PM
I answered this question for you on 15 May 2017, and you already accepted it as a solution. So why are you asking it again, and proving an answer that you are rejecting? Why don't you follow the answer that you already accepted?
Bob Schor
05-28-2017 01:23 PM
I'm sorry, but it's not the same question ,in any case thank you I found the solution
05-28-2017 09:02 PM
It sure sounds exactly the same.
05-28-2017 09:04 PM
The short answer is you can't because there really is no difference between a binary file and a text file except for how a human uses the data within. Therefore, you will have to determine an algorithm that resembles what would qualify as a text file for a human being.