2 ms·
I was wondering what the title meant. Turns out HN’s emoji stripper screwed with the title. It’s asking why a skin toned (not yellow) facepalm emoji’s length i
by colejohnson66 6y ago
I was wondering what the title meant. Turns out HN’s emoji stripper screwed with the title.
It’s asking why a skin toned (not yellow) facepalm emoji’s length is 7 when the user perceives it as a single character.
Tangent: Emojis are an interesting topic in regards to programming. They challenged the “rule” held by programmers that every character is a single codepoint (of 8 or 16 bits). So, str[1234] would get me the 1235th character, but it’s actually the 1235th byte. UTF-8 threw a wrench in that, but many programmers went along ignoring reality.
Sadly, preexisting languages such as Arabic weren’t warning enough in regards to line breaking. As in: an Arabic “character”[a] can change its width depending on if there’s a “character” before or after it (which gives it its cursive-like look). So, a naive line breaking routine could cause bugs if it tried to break in the middle of a word. Tom Scott has a nice video on it that was filmed when the “effective power” crash was going around.[0]
[0]: https://youtu.be/hJLMSllzoLA https://youtu.be/hJLMSllzoLA
[a]: Arabic script isn’t technically an alphabet like Latin characters are. It’s either an abugida or abjad (depending on who you ask). See Wikipedia: https://en.wikipedia.org/wiki/Arabic_script https://en.wikipedia.org/wiki/Arabic_script
- MengerSponge 6y agoInteresting. Also, many of us use fonts with ligatures, which render as a single character (for example: tt, ti, ff, Th, ffi) Of course, we're taught to parse that as multiple discrete letters from an early age, so we don't get confused :)