How this calculator works
Unicode assigns a number, called a code point, to every character in almost every writing system, from Latin letters to emoji. A code point is written as U+ followed by four or more hexadecimal digits. Text stored on a computer is encoded as bytes, and UTF-8 encodes each code point in one to four bytes: ASCII characters use one byte, most European and Middle Eastern characters use two, many East Asian characters use three, and emoji and other supplementary characters use four. HTML numeric entities spell a code point in decimal between an ampersand and a semicolon, which lets a page show a character without depending on its encoding.
Formula
Each character is read as a code point with its Unicode scalar value. UTF-8 uses the pattern 0xxxxxxx for values up to 127, 110xxxxx 10xxxxxx for values up to 2,047, 1110xxxx 10xxxxxx 10xxxxxx for values up to 65,535, and 11110xxx followed by three continuation bytes for values up to 1,114,111. The HTML entity is ampersand, number sign, the decimal code point, and semicolon.
Worked example
The letter A is U+0041, decimal 65, and one UTF-8 byte 41. The raised dot in a middle dot is U+00B7, decimal 183, and two UTF-8 bytes C2 B7. The emoji character with code point U+1F600 is four UTF-8 bytes F0 9F 98 80.
Advertisement
Frequently asked questions
Why does an emoji count as one character but two JavaScript code units?
Emoji above U+FFFF are stored in JavaScript strings as a surrogate pair of two 16-bit code units. This page works by code point, so the emoji appears once with a five-digit code point, while two code units would be needed to index it in a plain string.
What is the difference between a code point and a byte?
A code point is an abstract character number, while bytes are how that number is stored. U+00B7 is one character but two bytes in UTF-8, and the byte values depend entirely on the encoding used.
Why are the HTML entities all decimal?
Decimal numeric entities are universally supported and need no name table. Named entities such as & exist for common characters, but a numeric entity works for every assigned code point.
What happens to a combining accent?
It stays as its own code point, so a letter followed by a combining accent produces two entries. The page does not normalise the text, because that would silently change the characters the user typed.