How long is one emoji?
transcript
Take one grinning emoji. How long is that string? Four languages give different answers.
Python counts code points. The emoji is one. Java counts UTF sixteen units. The emoji is two. JavaScript counts the same units. Two. A C plus plus string counts bytes. Four.
Every character is a number. Unicode calls it a code point. This emoji is one hundred twenty eight thousand five hundred twelve. Storage then splits it into units or bytes.
Cut at index one in Java, and the emoji splits in half. You are left with half a character. Reverse it with split in JavaScript, and it breaks. Count code points, or the characters people see, instead.
The letter e with an accent can be one code point. Or it can be an e plus a separate accent. That is two. The two spellings look the same, but they are not equal. Normalise the text before you compare it.
Know what your length counts. Full breakdown in the lecture.