L
LLLOS.ai
Learn
L

Ask Your Tutor · Computer Science

How does UTF-8 actually store different languages in 1 to 4 bytes?

General knowledge In depth Asked by Anonymous from Orangeburg, United States 23 Oct 2026, 5:40 PM IST Updated

In one line

UTF-8 stores every character—no matter the language—using 1 to 4 bytes, by turning each character into a special pattern of bits that computers can read.

The rule

UTF-8 is a variable-length character encoding that uses 1 to 4 bytes to represent every Unicode character, allowing computers to store and share text from any language.

There is no single formula, but the rules are:

  • 1 byte for basic English letters and numbers (ASCII)
  • 2–4 bytes for other characters (like Hindi, Chinese, emoji)

Let's understand it simply

Imagine you have a giant box of crayons. Some colors are used every day (like blue and red), so you keep them in a small, easy-to-reach box. Rare colors (like gold or silver) are in a bigger, special box. UTF-8 works like this: common letters (A, B, C, 1, 2, 3) use just 1 byte—a small box. But for rare or special characters (like 'अ', '你', or '😊'), UTF-8 uses a bigger box—2, 3, or 4 bytes.

Think of bytes as small containers. Each byte has 8 bits (tiny switches that are on or off). UTF-8 packs the bits differently depending on the character. This way, English text stays small, but any language in the world can fit.

UTF-8 Byte Patterns
PatternBytes UsedExample Character
0xxxxxxx1A (English letter)
110xxxxx 10xxxxxx2अ (Hindi letter)
1110xxxx 10xxxxxx 10xxxxxx3€ (Euro sign)
11110xxx 10xxxxxx 10xxxxxx 10xxxxxx4😊 (Emoji)

How it works

  1. Every character is given a unique number (called a Unicode code point). For example, 'A' is 65, 'अ' is 2309, '你' is 20320.
  2. UTF-8 checks the code point's size:
  • If it's small (0–127), store it in 1 byte.
  • If it's bigger, use 2, 3, or 4 bytes.
  1. Each extra byte starts with a special pattern to show it's part of a multi-byte character:
  • 1 byte: 0xxxxxxx (x = data bits)
  • 2 bytes: 110xxxxx 10xxxxxx
  • 3 bytes: 1110xxxx 10xxxxxx 10xxxxxx
  • 4 bytes: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
  1. The rest of the bits hold the character's number (code point).
  2. When reading, the computer looks at the first bits to know how many bytes to read for each character.
How UTF-8 stores a character
  1. Find the Unicode number for the character
  2. Check if it fits in 1, 2, 3, or 4 bytes
  3. Pack the bits using the UTF-8 pattern
  4. Store or send the bytes
  5. Read the first bits to know how many bytes to use

The story behind it

In the early days, computers only understood English letters and numbers, using a system called ASCII (1 byte per character). But as computers spread worldwide, people wanted to write in Hindi, Tamil, Chinese, Arabic, and use emoji. Unicode was created to give every character in every language a number. UTF-8 was invented in 1992 by Ken Thompson and Rob Pike to store these numbers in a way that worked with old systems (ASCII) and new ones (Unicode), without wasting space.

A fun fact: UTF-8 became the most popular encoding on the web because it is backward-compatible with ASCII and can handle every language.

Where you see it in real life

  • WhatsApp messages: You can send 'Hello', 'नमस्ते', or '你好'—UTF-8 stores all of them.
  • Websites: Every page you read (news, Wikipedia) uses UTF-8 to show text in many languages.
  • Programming: When you write code in Python or Java, strings are stored in UTF-8.
  • File names: You can save a file as 'रिपोर्ट.txt' or '成绩单.docx' on your computer.
  • Emoji: Sending 😊 or 🚀 uses 4 bytes in UTF-8.
  • Databases: Banks, hospitals, and schools use UTF-8 to store names in any language.

Why it matters

  • Universal communication: Lets people read and write in their own language on any device.
  • Saves space: English text stays small (1 byte per letter), but any language is possible.
  • No data loss: Old systems (ASCII) and new ones (Unicode) work together safely.
  • Needed for exams and jobs: Understanding UTF-8 is key for computer science, web design, and software jobs.

Worked example

Let's see how UTF-8 stores 'A', 'अ', and '😊':

Given: 'A' (Unicode 65), 'अ' (Unicode 2309), '😊' (Unicode 128522)

Step 1: 'A' is 65 (binary: 01000001)
Step 2: 65 fits in 1 byte (0xxxxxxx)
Step 3: UTF-8: 01000001 (1 byte)

Step 4: 'अ' is 2309 (binary: 100100000101)
Step 5: 2309 needs 2 bytes (110xxxxx 10xxxxxx)
Step 6: UTF-8: 1100 1000 1000 0101 (C8 85 in hex)

Step 7: '😊' is 128522 (binary: 11111011000001010)
Step 8: Needs 4 bytes (11110xxx 10xxxxxx 10xxxxxx 10xxxxxx)
Step 9: UTF-8: 11110000 10011111 10011000 10001010 (F0 9F 98 8A in hex)

Common mistakes

  • Thinking every character uses 1 byte: Only basic English letters and numbers do. Others use more.
  • Confusing Unicode and UTF-8: Unicode is the list of all characters; UTF-8 is how they are stored.
  • Forgetting about multi-byte characters: Hindi, Chinese, emoji, etc., use 2–4 bytes, not just 1.
  • Assuming all bytes are the same: The first bits tell the computer how many bytes to read.

Remember it

UTF-8 = "One to four bytes for every character, any language, anywhere."

Check yourself

How many bytes does UTF-8 use to store the letter 'A'?

1 byte, because 'A' is a basic English letter (ASCII).

Why does UTF-8 use more bytes for Hindi or Chinese characters?

Because their Unicode numbers are bigger and need more space to store.

What is the main advantage of UTF-8 over older systems like ASCII?

UTF-8 can store any language's characters, not just English.

What do the first few bits in a UTF-8 byte tell the computer?

They show how many bytes make up the character.

Quick recap

  • UTF-8 stores every character using 1 to 4 bytes.
  • Common English letters use 1 byte; other languages and emoji use more.
  • The first bits in each byte show how many bytes the character uses.
  • UTF-8 lets computers handle any language together.
  • Unicode is the list of all characters; UTF-8 is how to store them.
Written by the LLOS.ai tutor. Asked by Anonymous from Orangeburg, United States on 23 Oct 2026, 5:40 PM IST