wpe41.gif (23084 bytes)CIS3355: Business Data Structures
Fall, 2008
 

What are ASCII Files??

Wait!! This is dumb question! All files are ASCII files, aren't they??

No, as a matter of fact, there are very few ASCII files, as opposed to non-ASCII files.

According to Webopedia an ASCII file is:

"A text file in which each byte represents one character according to the ASCII code. [This is in] contrast to a binary file, in which there is no one-to-one mapping between bytes and characters. Files that have been formatted with a word processor must be stored and transmitted as binary files to preserve the formatting. ASCII files are sometimes called plain text files. After it was (more or less) agreed upon that character sets would be developed using 7-bits, computer architects began building computers based on groupings of 7-bits and associated a unique symbol with each of the groupings."

What??

Let's first take a look at what a text file is. Suppose I wanted to store the phrase: "Hi, Mom". We already know that each character has a unique bit sequence associated with it. In this case, we would store the phrase (in binary) in a text file as:

Character: H i ,   M o m
ASCII Bit Sequence: 01001000 01101001 00101100 00100000 01001110 01101111 01101101

(Check the bit sequences in the ASCII table provided)

If we were writing this information to an ASCII file, we would store the binary sequences (in order) as:

0100100001101001001011000010110000100000010011100110111101101101

Where each eight bits (from left to right) represents the character being stored.

So?? How is that different that how a Microsoft Word file might save them?

I am not sure (exactly) how a Word package might save the data. However, it is obvious that Word saves a lot more information. For example, Word has to save information like Margins, fonts, line spacing, etc. Do you see any of these specifications in the ASCII Table (even in the Extended ASCII Character set??)

Obviously, our friends at Microsoft have their own scheme for storing data retrieving it and analyzing it. They can't store data using 8-bits, since they need to store more than 256 (As we know, 28 = 256 combinations) messages.

For the sake of argument, let's assume that they would store this information as:

Font, Font Size, string (i.e., "Hi, Mom"), endstring

Each of these components might require 32-bits of storage (232 = 4,294,967,296; a fair number of messages).

Let's again assume that the sequence of bits needed to store all of this information would be:

011000101011010101011000000110101101010101010101001111000000000000000000000000100
100000000000000000000000000001101001000000000000000000000000001011000000000000000
000000100111000000000000000000011011110000000000000011011010010111011010010011101

(using 320 bits, since each component requires 32-bits; don't bother trying to figure out the sequence; I've made most of it up)

Now, if we try and read this as if it were an ASCII file, we would take 8-bits at a time (from left to right) and analyze the sequence as:

8-Bit Sequence: 01100010 10110101 01011000 00011010 11010101 º º º º
ASCII Character: b  X SUB º º º º

And so on. This is (essentially) what you would see if you were to try and display contents of a Word, or Excel, or any other non-ASCII file using an ASCII Text editor. (Try it! Use an ASCII Text Editor, Such As Notepad, to open up a Word or Excel File and see what happens)

So what type of files are these non-ASCII files?

once again, our friends at Webopedia provide us with this definition:

[A binary file is] A file stored in binary format. A binary file is computer -readable but not human-readable. All executable programs are stored in binary files, as are most numeric data files. In contrast, text files are stored in a form (usually ASCII) that is human-readable.

What???

Basically, the users of a binary file know how to interpret the sequence of bits. We don't.

You can do that???

That's what data structures are all about.

Some good references include:

  1. What is an ASCII File?

  2. ASCII vs. Binary Files

  3. Digital Research Binary Files

At this point in time, you should be able to Answer the following questions:

  1. What is an ASCII File?

    "A text file in which each byte represents one character according to the ASCII code. [This is in] contrast to a binary file, in which there is no one-to-one mapping between bytes and characters. Files that have been formatted with a word processor must be stored and transmitted as binary files to preserve the formatting. ASCII files are sometimes called plain text files. After it was (more or less) agreed upon that character sets would be developed using 7-bits, computer architects began building computers based on groupings of 7-bits and associated a unique symbol with each of the groupings."
     
  2. How are ASCII Files read?

    An ASCII file is read 8-bits at a time (from left to right) and analyzed according to the ASCII sequence (as given in the ASCII Table)
     
  3. If we saw that the sequence of bits: 00110110101011100110000111011010, which is stored in a non-ASCII file, and tried to read it as if it were an ASCII file, what would we find?

    Taking the bits, 8 at a time (from left to right), we would find:
     
    8-Bit Sequence: 00110110 10101110 00110000 1101 1010      
    ASCII Character: 6 i 0      

     

  4. What is a binary file?

    [A binary file is] A file stored in binary format. A binary file is computer -readable but not human-readable. All executable programs are stored in binary files, as are most numeric data files. In contrast, text files are stored in a form (usually ASCII) that is human-readable.
     
  5. An ASCII File is:

    a.   A text file
    b.   A binary file
    c.   Either a Text file or a binary file
    d.   A file that reads 7-bits at a time (i.e., the standard ASCII Character set)
    e.   None of the above

    Answer: a
     
  6. ASCII Files:

    a.   Read 7 bits at time
    b.   Read 8 bits at time
    c.   Read bits as specified
    d.   None of the above
    e.   All of the above

    Answer: b
     
  7. A Binary file is:

    a.   A text file
    b.   An ASCII file
    c.   Either a Text file or an ASCII file
    d.   A file that reads 7-bits at a time (i.e., the standard ASCII Character set)
    e.   None of the above

    Answer: e
     
  8. Binary Files:

    a.   Read 7 bits at time
    b.   Read 8 bits at time
    c.   Read bits as specified
    d.   None of the above
    e.   All of the above

    Answer: c
     

This page was last updated on 01/08/05