ASCII

================

ASCII (American Standard Code for Information Interchange) is a character-encoding standard used to represent text and other data in digital systems. It is the most widely used encoding scheme in the world, with over 90% of all digital communication systems using it.

History


The first version of ASCII was introduced by Donald Knuth in 1962 as part of his book “TeX”. The original standard defined 128 characters that could be represented using two bytes each. Since then, the standard has been updated numerous times to include more characters and improve its efficiency.

In the 1970s, the US government passed a law requiring all computer systems to use ASCII in their communications. This led to widespread adoption of the standard across the world.

Standards


The American National Standard for Data Interchange (ANSI X3.79-1968) established the first widely accepted version of ASCII in 1968. This standard defined a binary code consisting of 56 characters, including control and formatting characters.

In 1982, the International Organization for Standardization (ISO) published an extension to ANSI X3.79, known as ISO/IEC 8859-1, which added support for non-Latin scripts.

Characters


ASCII uses a binary code of eight bits per character, with each bit representing one of 128 possible values. The standard is based on the Latin alphabet, but it also includes control characters such as newline (\n), tab (\t), and carriage return (\r) to separate lines in text.

The first seven bytes of an ASCII character code represent the binary representation of that character’s Unicode value. Characters are divided into three categories:

  • Control characters: These include special symbols, such as tab, newline, line feed, form feed, and backspace.
  • Formatting characters: These include control characters that change the appearance of text, such as bold or italic font.
  • Special characters: These include characters not part of the basic Latin alphabet, such as punctuation marks (!, @, #), digits (0-9), and hexadecimal characters.

Implementation


ASCII is used in a wide range of applications, including:

  • Text editors: Most text editors, such as Microsoft Word, use ASCII to render text.
  • Web browsers: Web browsers use ANSI X3.79 or ISO/IEC 8859-1 to display text on the screen.
  • Printers: Many printers output text in binary format using ASCII.

Security


ASCII is vulnerable to certain types of attacks, including:

  • Data corruption: Changes to a file can corrupt its contents by modifying the ASCII character set.
  • File access control: Access control systems may not be able to accurately determine the type of data being stored in a database or file system if it only uses ASCII.

Code Examples


Here are some examples of how ASCII is used in code:

C Example

#include <stdio.h>

int main() {
    printf("Hello, World!\n");
    return 0;
}

This C program outputs the string “Hello, World!” to the console.

Python Example

print("Hello, World!")

This Python program outputs the string “Hello, World!” to the screen.

Standards and Proposals


Several standards have been proposed or implemented for ASCII extensions:

  • ISO 8859-1: Proposed in 1982, this standard added support for non-Latin scripts.
  • ISO 8859-15: Implemented in 1990, this standard extended ISO/IEC 8859-1 to support more characters from the Latin alphabet and other languages.
  • UTF-8: Recommended by the International Organization for Standardization (ISO) in 2004, UTF-8 is an extension of ASCII that supports all Unicode characters.

Conclusion


ASCII is a widely used character encoding standard that has been adopted across the world. It is used in text editors, web browsers, printers, and many other applications. While it remains largely unchanged since its introduction in the 1960s, ongoing standards and proposals aim to improve its efficiency and support for non-Latin scripts.