← Glossary

What character encoding is

Last updated: 2026-11-02/~2 min

This article takes about 2 minutes to read.

Character encoding is the set of rules that assigns a number to each character and replaces that number with a sequence of bytes so computers can handle text. Unicode, UTF-8, and Shift_JIS are all kinds of these rules.In everyday use it is a single word, as in "What is the character encoding of this CSV?", but what it covers is split into several layers. It is the basic term to start from when you think about how emoji are stored and where they break.

Definition

Computers cannot remember characters directly, so they replace characters with numbers and store those. Character encoding is what decides which number goes to which character and what sequence of bytes is used to write that number. If the writer and the reader use the same character encoding, the original characters come back, and if they differ, the text turns into different characters.

In this glossary, the list of characters (character set), the way numbers are assigned, and the way they are written as bytes (encoding scheme) are together called character encoding. What the W3C explainer cited below calls character encoding is the layer of writing to bytes within this.

The 3 layers of character sets and encoding schemes

The W3C explainer "Character encodings: Essential concepts" separately describes the collection of usable characters (character set), the collection with a number assigned to each character (coded character set), and the method of mapping those numbers to bytes (character encoding). Laid out with the emoji 😀 (grinning face), it looks like this.

LayerWhat it decidesExample for 😀
Character setWhich characters are handledOne of the characters included in Unicode
Coded character setThe number for each character (codepoint)U+1F600
Encoding scheme (UTF-8)How the number is mapped to bytesF0 9F 98 80 (4 bytes)
Encoding scheme (UTF-16)Same as aboveD8 3D DE 00 (4 bytes, big-endian)
Encoding scheme (UTF-32)Same as above00 01 F6 00 (4 bytes, big-endian)

Even with a single number, the sequence of bytes differs from scheme to scheme. If you keep in mind that Unicode is the side that decides the numbers and UTF-8 is the side that decides how to write them as bytes, the topics do not get mixed up.

One character is not always one byte

The same W3C explainer warns that in Unicode the number of bytes rarely matches the number of characters. The Latin letter A is 1 byte in UTF-8, but the hiragana あ is 3 bytes and most emoji are 4 bytes, and the differences in byte count between schemes are summarized in the comparison table in the UTF-8 glossary entry.

Characters that take 4 bytes in UTF-16 are represented by a surrogate pair, which combines 2 units into a pair. When you count against a character limit or cut a string partway, emoji split in half and break unless you check which unit you are counting in.

Character encodings from before Unicode

In Japanese-language environments, character encodings made just for Japanese, such as Shift_JIS and EUC-JP, have been used since before Unicode spread. Even the same あ has completely different byte sequences: 82 A0 in Shift_JIS, A4 A2 in EUC-JP, and E3 81 82 in UTF-8. This is why a file turns into garbled text when you open it without knowing which character encoding it was written in.

These character encodings are also limited in the range of characters they can handle, and most emoji are not included in them. The W3C's "Choosing & applying a character encoding" lists EUC-JP as a scheme with interoperability problems that should be avoided on the Web.

Choosing a character encoding for the Web and its names

The W3C states that a single HTML page can use only one character encoding, and recommends choosing UTF-8 for all content.

The character encodings that browsers can read and their names are defined by the WHATWG "Encoding Standard". In this standard, each character encoding has one name and one or more labels, and browsers handle only the character encodings and labels listed in its table. Labels are matched after removing leading and trailing whitespace, without distinguishing uppercase from lowercase. For example, sjis, ms932, and windows-31j are all labels for Shift_JIS, so whichever one you write in the declaration, the page is read as Shift_JIS. iso-8859-1 and us-ascii are labels for windows-1252, and browsers read the byte 0x80 as € (U+20AC). For authors, it requires using UTF-8 and writing utf-8 as the label.

Common misconceptions

  • ❌ "Character encoding and Unicode are the same thing" → ✅ Unicode is one character encoding, and it corresponds to the layer that decides the numbers
  • ❌ "One character is one byte" → ✅ In UTF-8 it is 1 to 4 bytes, and most emoji are 4 bytes
  • ❌ "Rewriting the declaration also changes the content" → ✅ The declaration is an instruction on how to read, and the stored bytes themselves do not change

Related terms

  • Unicode - the standard that decides the number for each character
  • UTF-8 - the encoding scheme commonly used as standard on the Web
  • Surrogate pair - the mechanism that represents a supplementary character with 2 units in UTF-16

Was this article helpful?