Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Nope, nothing to do with surrogates either. Surrogates are code points encoded with 2 code units of 2 bytes each. A number of emoji, like the heart, are coded using multiple code points, which is even more bizarre.


> Nope, nothing to do with surrogates either. Surrogates are code points encoded with 2 code units of 2 bytes each.

Surrogates are actual codepoints, the range U+D800 to U+DFFF is reserved exclusively for that use: https://en.wikipedia.org/wiki/Universal_Character_Set_charac....

> A number of emoji, like the heart, are coded using multiple code points, which is even more bizarre.

Not really. It's a base codepoint plus some sort of combining/variation selector, not unlike e +‌ ‌́ = é e.g. U+2764 HEAVY BLACK HEART (which HN strips because as of 2018 HN's commenting system remains hot garbage) + U+FE0F VARIATION SELECTOR-16 = a red heart. That mechanic is also used to select skin tones on "people" emoji e.g. take U+1F476 BABY, add U+1F3FD EMOJI MODIFIER FITZPATRICK TYPE-4 and blamo light-brown baby. This allows a multiplicity of variants when useful without having to implement each combination individually.

There are emoji which are actually coded using multiple codepoints (not a base + modifiers): the country flags, which are pairs of regional indicator symbols composing ISO-3166 country codes e.g. U+1F1F1 REGIONAL INDICATOR SYMBOL LETTER L + U+1F1F8 REGIONAL INDICATOR SYMBOL LETTER S = 🇱🇸 (the flag of lesotho). Unpaired regional indicators display as crummy placeholders at best, they're not just modified, here's with an interstitial space: 🇱 🇸

"Family" emoji take it one step further (and into the "hack" realm imo), they're a bunch of independent emoji (possibly with their own variation selectors) "joined" by ZJW.


> Surrogates are actual codepoints, the range U+D800 to U+DFFF is reserved exclusively for that use:

Yes ... and no. In a UTF-16-encoded string, surrogates lose their status of code point (which they would have in a UTF-32- or a UCS-2-encoded string) and are mere code units instead.

The fact that the natural number they represent is reserved as code points is only a trick to band-aid systems that are trying to interpret buffers as UCS-2 although they are UTF-16.

> Not really. It's a base codepoint plus some sort of combining/variation selector, not unlike e +‌ ‌́ = é

I am pretty sure the combining marks and all these other things are technically still code points on their own. They're not glyphs, though: a glyph can be represented by multiple code points, as you mentioned one base code point (or two as in the flags) and potential combining marks/selectors/etc.

And then the families are indeed multiple glyphs with ligatures, AFAIU.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: