Free tutorials & notes in Hindi & English · Clean code examples 🧰 Free PDF & Image Tools →
🖥️ Unit 1 – Computer Systems & Organisation  ·  Lesson 06

Encoding: ASCII, ISCII & Unicode

What is encoding?

A computer can store only numbers in binary. So how does it store the word Hello or नमस्ते? We agree on a table in which every character gets a unique number (its code point). Converting characters into these codes is called encoding; converting codes back to characters is decoding.

You press AkeyboardCode 65encoding table01000001stored in memoryA on screendecoded with same table
Both sender and receiver must use the same encoding scheme
🤔 Ever seen "नमसà¥à¤¤à¥‡"?

That garbage appears when Hindi text saved in one encoding (UTF-8) is opened as another (Windows-1252). The bytes are fine; the decoding table is wrong.

ASCII

ASCII (American Standard Code for Information Interchange) was created in the 1960s to make computers and teleprinters exchange English text. It uses 7 bits, giving 128 codes (0–127):

  • 0–31 and 127: control characters (new line = 10, tab = 9) — not printed.
  • 32–126: printable characters — space, digits, A–Z, a–z and symbols.

Extended ASCII uses 8 bits (256 codes) for extra symbols, but different companies filled codes 128–255 differently.

Important ASCII codes to remember

CharacterDecimalBinaryPattern
space320100000first printable
0 … 948 … 570110000 …'0' is 48
A … Z65 … 901000001 …'A' is 65
a … z97 … 1221100001 …'a' = 'A' + 32
Learn four numbers: 32, 48, 65, 97

Trick: small letter = capital letter + 32. So D = 68 and d = 100. The word CAT is stored as 67 65 84.

ASCII in Python: ord() and chr()

ord(ch) gives the code of a character; chr(n) gives the character for a code.

Python
for ch in ['A', 'a', '0', ' ']:
    print(repr(ch), 'code =', ord(ch), 'binary =', format(ord(ch), '08b'))
print(chr(72) + chr(105))
'A' code = 65 binary = 01000001 'a' code = 97 binary = 01100001 '0' code = 48 binary = 00110000 ' ' code = 32 binary = 00100000 Hi

A fun use — a simple "secret code" that shifts each letter forward by one:

Python
word = 'CBSE'
codes = [ord(c) for c in word]
print(codes)
secret = ''.join(chr(c + 1) for c in codes)   # shift every letter by 1
print(secret)
[67, 66, 83, 69] DCTF

ISCII for Indian languages

ISCII (Indian Script Code for Information Interchange) was developed in India in the late 1980s. It is an 8-bit code: the first 128 codes are the same as ASCII, and codes 160–255 are used for letters of Indian scripts such as Devanagari, Bengali, Gurmukhi, Gujarati, Oriya, Tamil, Telugu, Kannada and Malayalam.

Because Indian scripts share the same structure (vowels, consonants, matras), one ISCII table could serve many scripts. Today, however, almost all Indian-language text on the web uses Unicode.

Unicode

Unicode is a universal standard that gives a unique number (written as U+ followed by hex) to every character of every writing system — Hindi, Urdu, Tamil, Chinese, Arabic, maths symbols and emoji. It has room for over a million code points. Its first 128 code points are the same as ASCII, so old English text still works.

A
U+0041Latin capital A (same as ASCII 65)
अ
U+0905Devanagari letter A
₹
U+20B9Indian rupee sign
😀
U+1F600Grinning face emoji
Every character has one Unicode code point

UTF-8, UTF-16 and UTF-32

Unicode gives the number; a UTF (Unicode Transformation Format) decides how many bytes are used to store it.

SchemeBytes per characterWhere used
UTF-81 to 4 (variable). English = 1 byte, Hindi = 3 bytesWeb pages, Python files, most of the internet
UTF-162 or 4Windows internals, Java
UTF-32Always 4 (fixed)Simple to process, but uses more space

Unicode in Python

Python 3 strings are Unicode, so Hindi works directly. encode('utf-8') shows the actual bytes stored.

Python
for ch in ['A', 'अ', '₹', '😀']:
    b = ch.encode('utf-8')
    print(ch, 'U+' + format(ord(ch), '04X'), len(b), 'byte(s)')
print(len('नमस्ते'), 'characters,', len('नमस्ते'.encode('utf-8')), 'bytes')
A U+0041 1 byte(s) अ U+0905 3 byte(s) ₹ U+20B9 3 byte(s) 😀 U+1F600 4 byte(s) 6 characters, 18 bytes

So the 6 characters of नमस्ते (न, म, स, ्, त, े) take 18 bytes in UTF-8, while "Hello" takes only 5.

Summary & practice

  • Encoding = mapping characters to numbers so they can be stored in binary.
  • ASCII: 7-bit, 128 characters, English only. A=65, a=97, 0=48, space=32.
  • ISCII: 8-bit code for Indian scripts.
  • Unicode: one code point for every character in the world; UTF-8 stores it in 1–4 bytes.
✅ Practice

1) Write the ASCII codes of the word "Py". 2) What character has code 90? 3) How many bits are needed to store "INDIA" in ASCII (8 bits per character)?

Answers: 1) P = 80, y = 121. 2) Z. 3) 5 × 8 = 40 bits.

Frequently Asked Questions

What is the ASCII code of A and a?
A is 65 and a is 97. Capital and small letters differ by exactly 32. The digit 0 is 48 and a space is 32.
How many characters can ASCII represent?
Standard ASCII uses 7 bits, so 2⁷ = 128 characters (codes 0 to 127). Extended ASCII uses 8 bits for 256 characters.
Why was Unicode needed?
ASCII covers only English. Different countries made different codes, so text became garbled when shared. Unicode gives one unique number to every character of every script, including Hindi, Tamil, Chinese and emoji.
← Class 11 Computer Science
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

Next topicBoolean Logic, Gates & Truth Tables Your progress: 6 / 29 (21%) · Lesson 7 / 29 Continue →

How was this lesson?

Your feedback helps us make the content better.

Write a review or suggestion (optional)

After approval, your name and city may appear publicly with your review. Please do not write your email or phone number.

▶ CodingEasily on YouTube

Learn with video lessons in easy Hindi

Featured video: RDBMS Part 3 – Class XI Commerce IT

▶ Subscribe – it’s free