Skip to main content
UTF-8 encodes each character as one to four bytes. ASCII characters take one byte, so for plain English text the byte count matches the character count. Accented letters, non-Latin scripts, and emoji take more.

Why the distinction matters

Byte-length limits. A database column declared VARCHAR(20) may count bytes, not characters, so a 20-character string with accents can overflow it. Request signing. HMAC signatures are computed over bytes. Your signature only matches if you sign the same encoding of the same string. This is why signing the exact serialized body matters, rather than re-serializing it. Truncation. Cutting a string at a byte offset can split a multi-byte character in half and produce invalid UTF-8. Always truncate on character boundaries.