Charsets and encoding

From A Technological Wiki
Revision as of 14:20, 7 November 2025 by Root (talk | contribs) (Created page with "= What is a character? = A '''character''' is a symbol that humans understand - like letters (a, ñ), numbers (3), or punctuation (?). Computers, however, only understand '''binary numbers''' (0 or 1). So, to represent characters in a computer, we need a '''mapping''' between characters and numbers. ---- = What is a charset (character set)? = A '''charset''' (short for "character set") is basically a ''table'' that assigns a unique number (a '''code point''') to each...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

What is a character?

A character is a symbol that humans understand - like letters (a, ñ), numbers (3), or punctuation (?).

Computers, however, only understand binary numbers (0 or 1).

So, to represent characters in a computer, we need a mapping between characters and numbers.


What is a charset (character set)?

A charset (short for "character set") is basically a table that assigns a unique number (a code point) to each character.

For example, in the ASCII charset:

Character Decimal Code Binary Representation
a 97 01100001
b 98 01100010
A 65 01000001

So when you type the letter "a", the computer actually stores the number 97 in memory.

Here is the full ASCII charset table


What is encoding?

An encoding defines how the numbers (code points) from a charset are stored in bytes.

Think of it like this:

  • Charset = Dictionary (maps letters to numbers)
  • Encoding = Packaging method (decides how to store those numbers in bytes)

Example with "a"

Let’s look at "a" in several encodings:

Encoding How "a" is stored (in bytes) Explanation
ASCII 01100001 → 0x61 Only one byte (97 in decimal). ASCII supports 128 characters.
UTF-8 01100001 → 0x61 Same as ASCII for English letters. UTF-8 is backward compatible with ASCII.
UTF-16 00000000 01100001 → 0x00 0x61 Uses two bytes for basic Latin letters.
UTF-32 00000000 00000000 00000000 01100001 → 0x00 0x00 0x00 0x61 Always uses 4 bytes per character.

So for the same “a”:

Charset Encoding Bytes Stored
ASCII ASCII 0x61
Unicode UTF-8 0x61
Unicode UTF-16 0x00 0x61
Unicode UTF-32 0x00 0x00 0x00 0x61