Live data from Hacker News

It’s not wrong that "🤦🏼‍♂️".length == 7 (2019)

hsivonen.fi

1–10 of 315 posts

Re: It’s not wrong that "🤦🏼‍♂️".length == 7 (2019)

#2
HN discards emojis in the title. The original emoji was https://emojipedia.org/man-facepalming-medium-light-skin-ton... which consists of 5 Unicode code points.

Also please make sure to read the first heading after the title, which summarizes the whole point of this essay.

Re: It’s not wrong that "🤦🏼‍♂️".length == 7 (2019)

#3

HN discards emojis in the title. The original emoji was https://emojipedia.org/man-facepalming-medium-light-skin-ton... which consists of 5 Unicode code points. Also please make sure to read the first heading after the title, which summarizes the whole point of this essay.

Was definitely confused on the meaning of that one haha. Thanks for the info!

Re: It’s not wrong that "🤦🏼‍♂️".length == 7 (2019)

#4
Measuring the length of text is really hard. Font fallback is hard. All of these things, you take for granted till you write your own game engine.

Apparently the thing to use is a library with a very strange name, which does glyph placement. I’ll go look for it.

EDIT: harfbuzz https://harfbuzz.github.io/why-do-i-need-a-shaping-engine.ht...

Re: It’s not wrong that "🤦🏼‍♂️".length == 7 (2019)

#5
> Python 3’s approach is unambiguously the worst one, though.

Did I miss the part where he explains this take? It's made up of 5 valid unicode code units. For a language where you're not supposed to need to know the byte size semantics, the correct length should be 5. What am I missing?

The close second being 17, because length in bytes. Is another fine way to represent this data, e.g. what a successful write of some sort would look like. Network or file.

I guess I'm basing this all on the idea that it's almost always a mistake to confuse how a program manages some data, vs how a drawing lib might. Your language shouldn't concern it self with how many glyphs it needs to draw... until you actually try to draw them.

Re: It’s not wrong that "🤦🏼‍♂️".length == 7 (2019)

#8

> Python 3’s approach is unambiguously the worst one, though. Did I miss the part where he explains this take? It's made up of 5 valid unicode code units. For a language where you're not supposed to need to know the byte size semantics, the correct length should be 5. What am I missing? The close second being 17, because length in bytes. Is another fine way to represent this data, e.g. what a successful write of some…

I think he meant to bring out defensiveness with that quip. He never says that it's a big deal, just that it's the worst way to get the length of a string containing emoji, presumably of the mainstream languages.

Re: It’s not wrong that "🤦🏼‍♂️".length == 7 (2019)

#9

Measuring the length of text is really hard. Font fallback is hard. All of these things, you take for granted till you write your own game engine. Apparently the thing to use is a library with a very strange name, which does glyph placement. I’ll go look for it. EDIT: harfbuzz https://harfbuzz.github.io/why-do-i-need-a-shaping-engine.ht...

Measuring the length of text is easy. Now measuring the length of text before actually printing it / running the shaping engine, now that's hard.

Re: It’s not wrong that "🤦🏼‍♂️".length == 7 (2019)

#10

Measuring the length of text is really hard. Font fallback is hard. All of these things, you take for granted till you write your own game engine. Apparently the thing to use is a library with a very strange name, which does glyph placement. I’ll go look for it. EDIT: harfbuzz https://harfbuzz.github.io/why-do-i-need-a-shaping-engine.ht...

[dead]
Post reply on HN