What is a code point?
A code point is simply the number Unicode gives a character. The fire emoji π₯ is code point U+1F525. Understanding code points clears up a lot of confusion about text and emoji.
The U+ notation
Code points are written as U+ followed by hexadecimal digits: U+0041 (A), U+00E9 (Γ©), U+1F600 (π). The range runs from U+0000 to U+10FFFF.
Code point β byte
A code point is an abstract number. How many bytes it takes to store depends on the encoding: in UTF-8, βAβ is 1 byte but π is 4 bytes. Don't confuse the character's identity (its code point) with its storage (its bytes).
Code point β what users see
What a person perceives as one character (a βgraphemeβ) can be several code points β an emoji with a skin tone, or a flag, is multiple code points combined. So βlengthβ in code points isn't the same as visible characters.
'π₯'.codePointAt(0).toString(16) // '1f525'
'π¨\u200dπ»'.length // 5 (multiple code units!)
Frequently asked questions
How do I find a character's code point?
In JavaScript, 'π₯'.codePointAt(0) returns the number; format it as hex and prefix U+.
Is a code point one byte?
No β a code point is a number that may take 1β4 bytes to encode, depending on the encoding.