OTHER USEFUL INFORMATION

What is ASCII?

ASCII is a character encoding standard that assigns specific numbers to letters, digits, punctuation and control characters.

The basic idea of ASCII

Computers store numbers, so text needed a shared convention. ASCII specifies, for example, that the uppercase letter A corresponds to the number 65, while the digit 0 corresponds to the number 48. Systems that understand the same codes can read the text consistently.

Examples of ASCII characters
CharacterDecimal codePurpose
A65Uppercase letter
a97Lowercase letter
048Digit character
!33Punctuation
LF10Newline control character

A brief history

ASCII stands for American Standard Code for Information Interchange. The standard was created in the 1960s so different computers and communication devices could exchange consistently encoded text. Basic ASCII uses 7 bits and has 128 possible values, from 0 to 127.

ASCII values in Java code

ASCII characters have the same numeric values as their Unicode code points, so a basic character can also be displayed as a number:

char raide = 'A';
int raidesKodas = raide;

System.out.println(raide);
System.out.println(raidesKodas);
Console output

A
65

The reverse is also possible: assign a numeric value to a char variable:

char simbolis = 66;

System.out.println(simbolis);
Console output

B

Where is ASCII used?

  • plain-text and source-code files;
  • command-line commands and output;
  • parts of internet, email and other communication protocols;
  • data exchange between older devices and systems;
  • checking English letters, digits and basic symbols.

ASCII, Unicode and UTF-8

ASCII contains only 128 basic characters, so it has no Lithuanian letters such as ą, ė or žor emoji. Modern systems use Unicode, which describes characters from many world languages. UTF-8 is a popular Unicode encoding whose first 128 values exactly match ASCII.

Java char is not limited to the ASCII table.

It stores one UTF-16 code unit, allowing it to represent many more characters than ASCII.