How do I know if a file is binary or not?

Hi All,
I am writing a simple program to scan the pattern of some ASCII files at some directory.
However, I want to filter out all of the binary file. I wonder if there is any way to test if the file is binary or not.
(note: can't use the file extension 'cause they could have the extension of the txt but still are binary file)
Thank You.

In general, you can't reliably.
ASCII? My native language contains non-ASCII characters (8th bit set). I thank you not to consider my language "binary". There are buggy programs out there that do, and refuse to work correctly with my text files.
There are character set encodings that have "escape characters" for multi-byte values. E.g. UTF-8 encodes non-ASCII characters as multi-byte entities that look like "binary data" when viewed byte-by-byte.
The presence of NUL bytes might be a hint. Unless someone writes e.g. straight Unicode into a file; lots of NULs for ASCII text there.
If you insist on writing xenophobic software, look for 8th bit set and characters less than space (excluding tab). And damn the furriners, they should all use English anyway.

Similar Messages

  • How do it know which backup files to keep and which to delete?

    How do you know which backup files to keep and which to delete?

    If you still have all devices, just delete all. They will re backup.

  • How do i know if a website is authentic or not?

    how do i know if a website is authentic or not?

    See Site Identity Button
    * https://support.mozilla.com/kb/Site+Identity+Button

  • How do I know if the apps are free or not if I already have them on my ipad??

    How do I know if the apps are free or not if I already have them on my ipad?? I have an ipad and it was open by another person's Apple ID and all the applications too. Now I have change the Apple ID by my name and I wanted to update the apps and I can't remember if the apps were free or not, and I don't want to delete them without knowing if they are free.

    When you buy an app the app is permanently allocated to the AppleID account you bought it through.  You can then download that app on up to five devices,  as many times as you want, without buying it again.  So deleting an App is not a big problem, you just log into your account in iTunes again, find the app, and instead of showing you a 'BUY' button it shows you a 'DOWNLOAD' or 'INSTALL' button.
    If you change the AppleID account  you use in your iPad then Apple will think you sold the iPad to someone else, and all the apps with that name will stop working anyway.
    But you can change the name and email address for an AppleID account, without moving to a new AppleID account, by following these instructions:
    http://support.apple.com/kb/ht5621

  • HT4061 How can I know that my iPad is original or not?

    How can I know that my iPad is original or not? If I can know, how?

    Do you think it's a fake iPad?
    Were you able to register it with no problems?
    https://supportprofile.apple.com/MySupportProfile.do
    Where did you buy it?  Can you compare it with iPads at an Apple store or reseller?

  • HT201328 how can I know whether my IME is blocked or not?

    How can I know whether my IME is blocked or not?

    Ask your wireless carrier.
    Where did you acquire this iPhone? Common scam
    is to sell iPhone in working condition so buyer can see
    it works, then seller reports iPhone as stolen/lost for
    insurance claim. Insurance company works with
    cellular provider to blacklist the iPhone and suddenly
    it no longer works.
    Or is your iPhone still locked to a wireless carrier as
    you imply in https://discussions.apple.com/thread/5001327?tstart=0

  • In Generic Extraction how can we know whether it is Delta Enabled or not?

    In Generic Extraction how can we know whether it is Delta Enabled or not?
    Thanks,
    Pramod.

    Hi Pramod,
    In R/3 use RSO2 tcode and enter your DS name and click "Change / Display" In this "Press F7 or Display Filed List" icon near to Generic Delta.In this Screen if Delta Update is Checked means it supports delta method  otherwise it won't support delta method.
    Note:Assign Points if it helps.
    -Arun.M.D

  • How do I know if my iPad supports Siri or not? It has iOS 7.

    How do I know if my iPad supports Siri or not? It has iOS 7.

    iPads 1 & 2 do not support Siri.
     Cheers, Tom

  • How do you know what folder/file to modify?

    Ok, I've had Sun Support on site and even they couldn't tell me exactly how this works and the Sun Support phone support is clueless...
    All I need to do is change the "look & feel" of the portal so how am I supposed to know what folder/file to modify to get what I need?
    Setup:
    * Nested Tabs setup and working
    * JSPTabContainer contains the following:
    * First Top Tab is:
    <Container name="MyNestedTabContainer" provider="JSPTabContainerProvider" merge="replace">
    * Then first inner tab is thus:
    <Container name="MyHomeTableContainer" provider="JSPTableContainerProvider" merge="replace">
    1) What folder do I modify to change the look of either tab? I tried changing the JSPTabContainer/tabs.jsp and nothing happens. Do I have to change the default/JSPTabContainerProvider/tabs.jsp file instead?
    2) There is also a banner line with "Sun One Portal Server" between the tabs, how do I get rid of this?
    I've spent hours scouring the files using trial and error to try and get rid of simple things like this and almost at the point to chuck the whole thing into the trash can. I could have created a portal using Tiles by now...

    I find it IMPOSSIBLE to believe that this is the
    recommended way to do things.I do not say it is the recommended way, I'm just telling this is a quick way I personally use to do it. Sorry if you do not find my script useful.
    Where or where is all of this directory creation and
    copying of files found in the documentation? I guess it is described in the Portal Server Desktop, look for "sesta" which is an example organization name use there.
    Where does it say that in order to make changes, you have
    to all of this?I do not say you have to do it, neither the documentation. That is just a recommendation I suggest to avoid messing with globally used files, and clearly isolating your work from what is provided with the product.
    Are we just supposed to find it all out via osmosis?I guess tha documentation and this developer's forum are a better option ...
    I am extremely frustrated with this product right now.Sorry about that.
    The display profile merging and the template directories form an extremely powerful tool, but with a learning curve longer that those found with simpler approaches.
    Once you got them though, you'll find they allow you to easily and elegantly cover a very wide range of needs that wouldn't be achievable otherwise.

  • How to know whether a file is opened  or not ?

    Hi all,
    How to know whether a file is opened by its editor or not ? File may be any of the type.

    There are platform-dependent commands that tell whether a file (or directory, port etc.) is used by which processes.
    [oracle@izsak ~]$ fuser .
    .:                    9299c
    [oracle@izsak ~]$ ps -p  9299 -f
    UID        PID  PPID  C STIME TTY          TIME CMD
    oracle    9299  9298  0 Apr25 pts/0    00:00:00 -bash
    [oracle@izsak ~]$ ls -l $fn
    -rw-r-----  1 oracle oinstall 111215876 Apr 25 19:05 /opt/oracle/product/AS/10g/R2/opmn/logs/OC4J~ebank~default_island~1
    [oracle@izsak ~]$ fuser $fn
    /opt/oracle/product/AS/10g/R2/opmn/logs/OC4J~ebank~default_island~1:  3746  3747  3748  3749  3750  3751  3752  3753  3754  3755  3756  3758  3761  3762  3765  3767  3769  3770  3771 18638 21605 21743 21744 21745 22140 22143
    [oracle@izsak ~]$ ps -p 3746 -f
    UID        PID  PPID  C STIME TTY          TIME CMD
    oracle    3746 26427  0 Apr23 ?        00:00:01 /opt/oracle/product/AS/10g/R2/jdk/bin/java -server -Djava.security.policy=/opt...

  • How to know if a file browser item is not null using javascript fucntion

    Hi
    <br><br>
    I tried to use javascript for validation. I have a file browser item named P55_FILE_NAME and I would like to know if this item is null or not before submit.
    <br>
    I wrote this function :<br><br>
    function validate_import(f_n){<br>
         if (trim(document.getElementByName(f_n).src) == "")<br>
         {<br>
         alert ("File name is empty.");<br>
         document.getElementByName(f_n).focus();<br>
         }<br>
         else{<br>
         doSubmit('SUBMIT');<br>
         }<br>
    } <br><br>
    When I press submit button I got an error, sounds like the src method does not exist in my input item. <br>
    Then, I looked my source page an I found this :<br><br>
    input type="file" name="p_t01" size="30"
    <br><br>
    there is know src method and the name is not P55_FILE_NAME and I don't want to use <b>p_t01</b> that will change.<br>
    <br>
    I need your help.<br>
    Benn

    Hello,
    The p_txx notation is the internal name the ApEx engine attaches to each page item. It starts with p_t01 (for the first item on page) and can end with p_t99 (hence, the max 99 items per page limit). You can see these names in your HTML source code.
    The bug in the File Browse item (fixed in version 2.2) is that the ID of the item is the internal name instead of the item name. Hence, in order to use DOM, you need to use this internal notation.
    If the File Browse item id is p_t01, you can null its content by using something like that (V2.0 notation) :
    html_GetElement('p_t01').value = '';I'm using the same, and similar code, for manipulating this type of item with no problems.
    Please document the use of this workaround, as when you'll upgrade your ApEx system, you will have to change this code back to the standard – item id equal item name.
    (Please follow Scott's advise, and keep your logic connected issues on the same thread. It will get you more quick and accurate help).
    Regards,
    Arie.

  • When trying to download & install Firefox 5.0.1 into a Mac, I get a message saying that Firefox cannot be installed because libnsscksi.dylib is in use. Any idea how to locate and close that file? Finder does not recognize it. Thanks!

    Tried to install both Firefox 5.0 and 5.0.1, and received the same error message that a file ending in .dylib was in use. I cannot locate that file, and Finder does not recognize it.

    I have a Power PC Mac with OS 10.5.8 and Firefox 3.6.28, the latest versions supported on my machine, and all of my plug-ins are the latest versions available for that browser version. I too get the warning message all the time and it is very annoying. I have never had any "security" problems, and I don't go along with this imperative to always be upgrading equipment. Don't these corporate geeks understand that we're in a global economic contraction and a lot of us are unemployed/underemployed? They want us to be good consumers and "switch to a newer computer" but I can't afford that. Like, if I can't fix my old car, I won't be able to drive. What I want to know is: '''how to disable the warning message?''' Thank you in advance.

  • I want to know that two file are same or not.

    Hello.
    My English ability very poor.. sorry
    I want to compare two file
    if file is same return true
    else return false;
    I select file using JFileChooser.
    and read the file using fileinpustream
    then, trans byte array using byteArrayOutputStream..
    I use equlas() method...
    file1Array.equals(file2Array)
    I want to know two file are same or not
    How can I...

    If you want to test whether the two files are the same, you can test for their complete filename (path + filename).
    If you want to test whether the content of the two files are the same, you can convert the byteArrayOutputStream to Strings using .toString()method and test their equality. You can test for their size before the convertion to speed up the testing speed. E.g.
    ByteArrayOutputStream s1 = ...
    ByteArrayOutputStream s2 = ...
    if (s1.size() == s2.size()) {
    return s1.toString().equals(s2.toString());
    } else {
    return false;
    }

  • How can I print to a file? Msg: "Could not open the file, access denied"

    How can I print to a file? Printing itself works fine, but I get this error message when I select the "print to file" box.

    Hi gag5212, the "Print pages to PDF" extension does not use the normal print dialog. Instead, right-click the page and look for its menu there, or you can add its button to one of your toolbars.
    I'm surprised by your results with the other sites.
    The http://www.primopdf.com/ page layout is completely whacky. The product was acquired by the NitroPDF people, but what is going on here? Probably best to ignore that one for now.
    On http://www.pdfforge.org/ you should get something like the attached on the download page. I'm alarmed to hear you got something strange. Do you have any extensions that you don't recognize? You might be infected with something that redirects your downloads in some way. Although Norton is generally a solid product, you should consider some supplemental scans. This article lists tools that other Firefox users have found helpful: [[Troubleshoot Firefox issues caused by malware]]

  • How do I know whether my phone is unlocked or not?

    Hello
    I am in Thailand trying to activate my iphone 4S with Thailand SIM card.
    but the phone message says below.
    This iPhone is not currently setup to work with carrier you're attempting to use. Please insert another SIM card from a supported carrier or request that this iPhone be unlocked.
    so my question is how do I know whether my phone is unlocked one or not, before I go and try get new SIM card.
    Thank you very much. Your reply will be very much appreciated.

    If your phone will not work with another sim card, then it is likely to be locked to the original carrier.
    The only way to get your phone unlocked is to contact that phone company/carrier that the phone is locked to and hope that they offer unlocking.  Apple cannot unlock a phone for you, only the phone company that your phone is locked to can do that.  Some offer unlocking and some don't, so if the phone company does not offer unlocking, then you are out of luck and you'll either have to buy a new phone or use a sim card of the comapny - take out a contract with the compnay that the phone is locked to.
    Anyway - contact Apple to see whether your phone is locked conclusively and if you talk to them they can tell you what they need.

Maybe you are looking for