UTF-8 Character Encoding Guide

UTF-8 is a variable-length Unicode encoding that stores each code point in one to four bytes. ASCII characters keep their familiar one-byte values, while accented letters, symbols, and emoji use additional bytes.

Typical UTF-8 Byte Lengths

CharacterCode pointUTF-8 bytesLength
AU+0041411 byte
éU+00E9C3 A92 bytes
U+20ACE2 82 AC3 bytes
😀U+1F600F0 9F 98 804 bytes

Declare UTF-8 in HTML

Place <meta charset="utf-8"> near the beginning of the document head and serve the page with a matching HTTP Content-Type header. Save the source file itself as UTF-8. A declaration cannot repair bytes that were saved using a different encoding.

Why Garbled Text Appears

Mojibake occurs when bytes encoded one way are decoded another way. A common example is UTF-8 bytes interpreted as Windows-1252, producing sequences such as é instead of é. Replacement characters such as � often indicate invalid or lost byte sequences.