Introduction to Operating Systems

Introduction to Operating Systems

Sections: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Index | Next >

Binary and ASCII files

Learning objective: Explain the difference between ASCII and binary files

Display of binary through ASCII filter
Click on image to enlarge.

From the operating system's perspective, a file is either an ASCII file or a binary file. The default process of the operating system is to convert 1s and 0s through the ASCII table. If the file *is* an ASCII file, the user will be able to view the contents of the file or interaction with the computer as a "normal" text event. If the the file is something other than an ASCII file, like a picture which uses another bit pattern that is not ASCII, another application will be needed to view or modify the file, like Microsoft Paint, to properly process the unique set of 1s and 0s that make up a document like a picture.

For example, as binary set of 1000011110000111000101110011 could represent the word "Cabs" in ASCII *or* the value of 142,111,091 *or* a pixel in an image. It all depends on how the 1s and 0s get processed.

ASCII files

The American Standard Code for Information Interchange is a character-encoding scheme based on the ordering of the English alphabet. ASCII codes represent text in computers, communications equipment, and other devices that use text. Most modern character-encoding schemes are based on ASCII, though they support many more characters than did ASCII. When opened by a text editor, human-readable content is presented to the user. This often consists of the file's plain text visible to the user. Depending on the application, control codes may be rendered either as literal instructions acted upon by the editor, or as visible escape characters that can be edited as plain text. Though there may be plain text in a text file, control characters within the file (especially the end-of-file character) can render the plain text unseen by a particular method.

The purpose of using plain text today is primarily a "lowest common denominator" independence from programs that require their very own special encoding or formatting (with due sacrifices and limitations). Plain text files can be opened, read, and edited with most text editors. Examples include Notepad (Windows), edit (DOS), ed, emacs, vi, vim, Gedit or nano (Unix, Linux), SimpleText (Mac OS), or TextEdit (Mac OS X). Other computer programs are also capable of reading and importing plain text. It can also be used by simple computer tools such as line printing text commands like type (DOS and Windows) and cat (Unix). Plain text files are almost universal in programming; a source code file containing instructions in a programming language is almost always a plain text file. Plain text is also commonly used for configuration files, which are read for saved settings at the startup of a program.

Binary files

A binary file is a computer file which may contain any type of data, encoded in binary form for computer storage and processing purposes; for example, computer document files containing formatted text. Many binary file formats contain parts that can be interpreted as text; binary files that contain only textual data—without, for example, any formatting information—are called plain text files. In many cases, plain text files are considered to be different from binary files because binary files are made up of more than just plain text. When downloading, a completely functional program without any installer is also often called program binary, or binaries (as opposed to the source code).

Binary files are usually thought of as being a sequence of bytes which means the binary digits (bits) are grouped in eights. Binary files typically contain bytes that are intended to be interpreted as something other than text characters. Compiled computer programs are typical examples; indeed, compiled applications (object files) are sometimes referred to, particularly by programmers, as binaries. But binary files can also contain images, sounds, compressed versions of other files, etc. -- in short, any type of file content whatsoever. To view a binary, an application will be required to process it into something users can use if it is not ASCII.

The Rosetta Stone effect

The Rosetta Stone is a fragment of an Ancient Egyptian granodiorite stele, the engraved text of which provided the key to the modern understanding of Egyptian hieroglyphs. The inscription records a decree that was issued at Memphis in 196 BC on behalf of King Ptolemy V. The decree appears in three texts: the upper one is in ancient Egyptian hieroglyphs, the middle one in Egyptian demotic script, and the lower text in ancient Greek. Before the discovery of the Rosetta Stone, scholars had been trying to decrypt the the hieroglyphs for centuries. Since the other two languages on the stone were well understood, it was possible to understand the secrets of hieroglyphs. Within 20 years of the discovery of the stone, scholars could now study hieroglyphs and could walk into any Ancient Egyptian temple or tomb and read the writings on the walls nearly effortlessly. The ASCII table acts the same way. It translates the binary data into recognized characters that we humans can use. The default process of the command line interface for most operating systems is to attempt to filter binary data through the ASCII table. If the file is an ASCII or plain text file, users can easily view the data at the console or in a text editor like Notepad. If the data is *not* ASCII data, another process will be needed to make the data usable. For example, a series of 1s and 0s will be converted into pixels that makeup a portion of an image based on the sequence that is needed for that pixel, like 24 bits instead of 8 for ASCII.

Thinking: Why not make all data ASCII?

Key terms: ASCII, binary, plain text

Resources:
To maximize your learning, please visit these Web sites and review their content to help reinforce the concepts presented in this section.

Quick links:
ASCII @ Wikipedia
Text file @ Wikipedia
Plain text @ Wikipedia
Binary file @ Wikipedia
Rosetta Stone @ Wikipedia

Embedded Resources

Notes on navigation: Click inside the frame to navigate the embedded Web page. - Click outside the frame to navigate this page to scroll up/down between the embedded Web pages. - Click on the frame title to open that page in a new tab in most browsers. - Click on the the "Reload page" link to reload the original page for that frame.

ASCII @ Wikipedia | Reload page | If frame is empty, click on the link to view the page in a new tab or window

Text file @ Wikipedia | Reload page | If frame is empty, click on the link to view the page in a new tab or window

Plain text @ Wikipedia | Reload page | If frame is empty, click on the link to view the page in a new tab or window

Binary file @ Wikipedia | Reload page | If frame is empty, click on the link to view the page in a new tab or window

Rosetta Stone @ Wikipedia | Reload page | If frame is empty, click on the link to view the page in a new tab or window

Sections: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Index | Next >