L
LLLOS.ai
Learn
L

Ask Your Tutor · Computer Science

How do other encodings like UTF-16 work?

General knowledge Asked by Anonymous from Frankfurt, Germany 23 Oct 2026, 10:40 PM IST Updated

In one line

UTF-16 is a way to turn every letter, emoji, or symbol into numbers so computers can store and share them.

The rule

UTF-16 is a character encoding that uses 16 bits (2 bytes) for most characters, but can use 32 bits (4 bytes) for some special symbols.

  • Each character is stored as one or two 16-bit units.
  • Basic characters: 1 unit (2 bytes)
  • Rare/special characters: 2 units (4 bytes)

Let's understand it simply

Imagine you want to send a letter to your friend, but you both only understand numbers. You decide to give every letter, number, and symbol a special number. This is what encoding means.

In UTF-16, most common letters (like A, B, क, 你) get a number that fits in 2 bytes (16 bits). But if you want to send a rare emoji or an ancient script, you might need 4 bytes (32 bits). It's like using one envelope for most letters, but sometimes you need two envelopes for a big card!

UTF-8 vs UTF-16 vs ASCII
ASCIIUTF-8UTF-16
Bytes per character11–42 or 4
Languages supportedEnglish onlyAllAll
Emoji supportNoYesYes
File size for Hindi word (e.g., भारत)Not possible9 bytes10 bytes

How it works

  1. Every character is given a unique code number (called a code point).
  2. If the code point is less than 65,536 (hex 0xFFFF), it fits in one 16-bit unit.
  3. If the code point is bigger (like some emojis), it uses two 16-bit units (called a surrogate pair).
  4. The computer stores or sends these numbers, not the actual letters.
  5. When reading, the computer changes the numbers back to letters or symbols.
How UTF-16 Encodes a Character
  1. Pick a character (e.g., 😊)
  2. Find its Unicode code point (e.g., U+1F60A)
  3. Check if it fits in 16 bits (No, so use 2 units)
  4. Split into two 16-bit numbers (surrogate pair)
  5. Store or send these numbers

The story behind it

Before UTF-16, computers used different encodings for different languages (like ASCII for English, ISCII for Indian scripts), which made sharing files hard. Unicode was created to give every symbol in every language a unique number. UTF-16 was made in the 1990s as a way to store these numbers efficiently, especially for Asian languages where most characters fit in 16 bits.

Where you see it in real life

  • Windows computers often use UTF-16 for text files and system messages.
  • Many programming languages (like Java and JavaScript) use UTF-16 for storing strings.
  • When you see emojis on your phone, they are often stored using UTF-16.
  • Some web pages use UTF-16 to handle many languages at once.
  • Text in Microsoft Word or Notepad can be saved as UTF-16.

Why it matters

  • Lets computers show and share text in any language, including Hindi, Tamil, Chinese, and emojis.
  • Helps programmers write apps that work worldwide.
  • Used in exams and coding interviews (like CBSE Computer Science).
  • Needed for safe data sharing between different devices and platforms.

Common mistakes

  • Thinking every character always takes 2 bytes: Some need 4 bytes in UTF-16.
  • Mixing up UTF-8 and UTF-16: UTF-8 uses 1–4 bytes per character, UTF-16 uses 2 or 4 bytes.
  • Forgetting that not all software supports UTF-16 (some use UTF-8 or others).

Remember it

UTF-16: Most letters = 2 bytes, rare ones (like some emojis) = 4 bytes.

Check yourself

How many bytes does UTF-16 use for most common letters?

2 bytes, because most code points fit in 16 bits.

Why does UTF-16 sometimes use 4 bytes for a character?

Some rare symbols or emojis have code points above 65,535, so they need two 16-bit units.

Is UTF-16 the same as UTF-8? Why or why not?

No. UTF-8 uses 1–4 bytes per character, UTF-16 uses 2 or 4 bytes.

Quick recap

  • UTF-16 stores most characters in 2 bytes, but some need 4 bytes.
  • It can handle all world languages and emojis.
  • Used in Windows, Java, and many modern apps.
  • Not every character is the same size in UTF-16.
  • UTF-16 is different from UTF-8 and ASCII.
Written by the LLOS.ai tutor. Asked by Anonymous from Frankfurt, Germany on 23 Oct 2026, 10:40 PM IST