ASCII ( American Standard Code for Information Interchange) is a character encoding standard used in computers and communication equipment to represent text, control characters, and other data. ASCII was first developed in the 1960s and has been widely used since then.
The ASCII standard uses a 7-bit binary code to represent each character, allowing for a total of 128 different characters. These characters include basic Latin letters (both uppercase and lowercase), digits, punctuation marks, special symbols, and control characters. The original ASCII standard defines characters from 0 to 127, with each value representing a specific character.
For example:
- The ASCII code for the letter ‘A’ is 65 (01000001 in binary).
- The ASCII code for the letter ‘a’ is 97 (01100001 in binary).
- The ASCII code for the digit ‘0’ is 48 (00110000 in binary).
- The ASCII code for the exclamation(!)is 33 (00100001 in binary).
Since 7 bits provide only 128 possible values, ASCII has limitations for representing characters from languages with more characters, like Chinese, Japanese, or Cyrillic. As a result, various extended versions of ASCII, such as UTF-8 (Unicode Transformation Format 8-bit) and UTF-16, were developed to support a broader range of characters and cover multiple languages.
UTF-8 is currently the most widely used character encoding, as it is backward compatible with ASCII, meaning that the first 128 characters of UTF-8 are identical to ASCII, allowing ASCII-based software and systems to process UTF-8 encoded text without any issues.
Java Program to print the ASCII value
Example…
class ascii
{
public static void main(String aa[])
{
char ch;
int x=30;
do
{
ch=(char)x;
System.out.print(ch+” “);
if(x%25==0)
System.out.println();
x++;
}
while(x<=255);
}
}
Explanation…
In this example, we use a do-while loop….
The working of the do-while loop is the same as the while loop except for the fact that the condition is checked at the end of the loop. So the do-while loop is also called the Exit Controlled loop. The effect of this checking is that even if the condition is not fulfilled, the statements in the body of the loop will be executed at least once. So the minimum number of times a do-while loop runs is 1.
In the while loop, the test condition is checked at the beginning of the loop, but in the do-while, the test condition is checked at the end of the loop.